Example #1
0
    /// <summary>
    /// 绑定数据
    /// </summary>
    public void Bind()
    {
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        if (ViewState["strwhere"] != null)
        {
            strwhere += ViewState["strwhere"].ToString();
        }

        if (this.txtPager.Value.Trim().ToString() != "")
        {
            Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
        }
        //已经支付的订单
        // strwhere += "and PayState =" + (int)Enums.PayState.已支付 + " and isnull(dr,0)=0"; //isnull(dr,0)=1  订单已删除
        //所属企业的销售订单
        strwhere += " and compid=" + CompID;

        //订单状态已审核
        strwhere += "and Otype!=9 and OState=2 ";

        //List<Hi.Model.DIS_Order> l = OrderInfoBLL.GetList(Pager.PageSize, Pager.CurrentPageIndex, "ReceiptNo", true, strwhere, out pageCount, out Counts);
        DataTable l = new Hi.BLL.PAY_PrePayment().GetList_ggh(Pager.PageSize, Pager.CurrentPageIndex, "ReceiptNo", true, strwhere, out pageCount, out Counts);

        this.rptOrder.DataSource = l;
        this.rptOrder.DataBind();

        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #2
0
    /// <summary>
    /// 根据不同的状态,显示不同的操作按钮
    /// </summary>
    /// <param name="state"></param>
    /// <param name="id"></param>
    /// <returns></returns>
    public string Getmessage(int state, int id, int paystate, int ostate)
    {
        state = 1;
        string str = string.Empty;

        //str = string.Format("<a href=\'javascript:void(0)\' onclick=\'pay({0},{1})\' class=\"tablelink\">补录</a>", id,state);


        if (paystate != 2)
        {
            if (Common.HasRight(this.CompID, this.UserID, "1112"))
            {
                if (ostate != 6)
                {
                    str = string.Format("<a href=\'javascript:void(0)\' onclick=\'pay({0},{1})\' class=\"tablelinkQx\">账单补录</a>", id, state);
                }
            }
        }
        else
        {
            DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("ID", "pay_prepayment", "PreType=7 and OrderID=" + id);
            if (dt.Rows.Count > 0)
            {
                id = Convert.ToInt32(dt.Rows[0][0]);
            }
            str += string.Format("<a href=\'javascript:void(0)\' onclick=\'goPreInfo({0})\' class=\"tablelinkQx\">补录详情</a>", id);
        }
        return(str);
    }
Example #3
0
    /// <summary>
    /// 转账汇款审核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSh_Click(object sender, EventArgs e)
    {
        string shId = this.hidShId.Value;

        //调用model,对属性进行赋值
        Hi.Model.PAY_PrePayment shModel = new Hi.BLL.PAY_PrePayment().GetModel(Convert.ToInt32(shId));
        shModel.AuditState = 2;
        //调用修改方法
        Hi.BLL.PAY_PrePayment shUpdate = new Hi.BLL.PAY_PrePayment();
        bool shUp = shUpdate.Update(shModel);

        if (shUp == bool.Parse("true"))
        {
            int hidShIds = shModel.DisID;
            Hi.BLL.PAY_PrePayment prePayModel = new Hi.BLL.PAY_PrePayment();
            //sum代理商全部录入,冲正以及审核通过的转账汇款金额
            decimal sums = prePayModel.sums(hidShIds, shModel.CompID);
            //修改代理商的企业钱包金额
            //调用model,对属性进行赋值
            Hi.Model.BD_Distributor disSumModel = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(hidShIds));
            disSumModel.DisAccount = sums;
            disSumModel.ID         = shModel.ID;
            //调用修改方法
            Hi.BLL.BD_Distributor disupdate = new Hi.BLL.BD_Distributor();
            bool disup = disupdate.Update(disSumModel);
            if (disup)
            {
                JScript.AlertMethod(this, "审核成功", JScript.IconOption.笑脸, "function (){ location.replace('" + ("PayExamineList.aspx") + "'); }");
            }
        }
    }
Example #4
0
    public void Bind()
    {
        DataTable PayDetail = new Hi.BLL.PAY_PrePayment().GetPayedItem(KeyID);

        this.rptPayDetail.DataSource = PayDetail;
        this.rptPayDetail.DataBind();
    }
Example #5
0
    /// <summary>
    /// 新建冲正企业钱包
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //定义冲正的变量
        string txtPayCorrectDis   = string.Empty;
        string txtPayCorrectPrice = string.Empty;
        //string txtPayCorrectDate = string.Empty;
        string txtPayCorrectType   = string.Empty;
        string txtPayCorrectRemark = string.Empty;

        //获取冲正输入的数据
        txtPayCorrectDis   = this.txtPayCorrectDis.Value.Trim().ToString();
        txtPayCorrectPrice = this.txtPayCorrectPrice.Value.Trim().ToString();
        //txtPayCorrectDate = this.txtPayCorrectDate.Value.Trim().ToString();
        txtPayCorrectType   = this.txtPayCorrectType.Value.Trim().ToString();
        txtPayCorrectRemark = this.txtPayCorrectRemark.Value.Trim().ToString();
        //调用model,对属性进行赋值
        Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.Model.PAY_PrePayment();
        prepaymentmodel.CompID     = 1;
        prepaymentmodel.DisID      = Convert.ToInt32(txtPayCorrectDis);
        prepaymentmodel.Start      = 1;
        prepaymentmodel.PreType    = Convert.ToInt32(txtPayCorrectType);
        prepaymentmodel.price      = -Convert.ToDecimal(txtPayCorrectPrice);
        prepaymentmodel.Paytime    = DateTime.Now;
        prepaymentmodel.CreatDate  = DateTime.Now;
        prepaymentmodel.CrateUser  = 1;
        prepaymentmodel.AuditState = 0;
        prepaymentmodel.IsEnabled  = 1;
        prepaymentmodel.ts         = DateTime.Now;
        prepaymentmodel.dr         = 1;
        prepaymentmodel.modifyuser = 1;
        prepaymentmodel.vdef1      = txtPayCorrectRemark;
        //调用保存方法
        Hi.BLL.PAY_PrePayment prepaymentsave = new Hi.BLL.PAY_PrePayment();
        int reslut = prepaymentsave.Add(prepaymentmodel);

        //判断返回值int
        if (reslut > 0)
        {
            //sum代理商全部录入,冲正金额
            //decimal sums = prepaymentsave.sums(txtPayCorrectDis);
            //修改代理商的企业钱包金额
            //调用model,对属性进行赋值
            //Hi.Model.BD_Distributor dismodel = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(txtPayCorrectDis));
            //dismodel.DisAccount = sums;
            //调用修改方法
            //Hi.BLL.BD_Distributor disupdate = new Hi.BLL.BD_Distributor();
            //bool disup = disupdate.Update(dismodel);

            JScript.AlertMethod(this, "冲正成功!", JScript.IconOption.笑脸, "function (){ location.replace('" + ("PayCorrectList.aspx") + "'); }");
        }
        else
        {
            JScript.AlertMethod(this, "冲正失败!", JScript.IconOption.哭脸, "function (){ location.replace('" + ("PayCorrectList.aspx") + "'); }");
        }
    }
Example #6
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //定义冲正的变量
        string txtPayCorrectDis   = string.Empty;
        string txtPayCorrectPrice = string.Empty;
        //string txtPayCorrectDate = string.Empty;
        string txtPayCorrectType   = string.Empty;
        string txtPayCorrectRemark = string.Empty;

        //获取补录金额,输入的数据
        txtPayCorrectPrice = Common.NoHTML(this.txtPayCorrectPrice.Value.Trim());
        if (Convert.ToDecimal(txtPayCorrectPrice) <= 0)
        {
            JScript.AlertMethod(this, "操作失败,补录金额不能小于或等于零!", JScript.IconOption.错误, "function (){ location.replace(); }");//'" + ("PayCreateAdd.aspx?UID="+Uid) + "'
            return;
        }
        txtPayCorrectRemark = Common.NoHTML(this.txtRemark.Value.Trim());
        txtPayCorrectDis    = Common.NoHTML(this.hidDisUserID.Value);// this.DisListID.Disid;//获取代理商ID
        //调用model,对属性进行赋值
        Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.Model.PAY_PrePayment();
        prepaymentmodel.CompID     = this.CompID;
        prepaymentmodel.PreType    = 2;
        prepaymentmodel.vdef3      = this.ddltype.Value;//来源
        prepaymentmodel.DisID      = Convert.ToInt32(txtPayCorrectDis);
        prepaymentmodel.Start      = 1;
        prepaymentmodel.price      = Convert.ToDecimal(txtPayCorrectPrice);
        prepaymentmodel.Paytime    = DateTime.Now;
        prepaymentmodel.CreatDate  = DateTime.Now;
        prepaymentmodel.CrateUser  = this.UserID;
        prepaymentmodel.AuditState = 2;//2已审,0 未审
        prepaymentmodel.IsEnabled  = 1;
        prepaymentmodel.ts         = DateTime.Now;
        prepaymentmodel.dr         = 0;
        prepaymentmodel.modifyuser = this.UserID;
        prepaymentmodel.vdef1      = txtPayCorrectRemark;
        prepaymentmodel.vdef5      = hrOrderFj.Value;  //保存附件的名称
        prepaymentmodel.vdef6      = ddlPaytype.Value; //支付方式
        //调用保存方法
        Hi.BLL.PAY_PrePayment prepaymentsave = new Hi.BLL.PAY_PrePayment();
        int reslut = prepaymentsave.Add(prepaymentmodel);

        //判断返回值int
        if (reslut > 0)
        {
            Utils.AddSysBusinessLog(this.CompID, "PrePayment", reslut.ToString(), "预收款补录新增", prepaymentmodel.vdef1);
            // JScript.AlertMsg(this, "操作成功", "PayCreateInfo.aspx?KeyID=" + reslut);
            Response.Redirect("PayCreateInfo.aspx?KeyID=" + Common.DesEncrypt(reslut.ToString(), Common.EncryptKey));
        }
        else
        {
            JScript.AlertMethod(this, "操作失败!", JScript.IconOption.错误, "function (){ location.replace(); }");//'" + ("PayCreateInfo.aspx") + "'
        }
    }
Example #7
0
    //public void DropListBind()
    //{
    //    DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("id,disname", "BD_Distributor", "compid=" + this.CompID);
    //    int i = 1;
    //    foreach (DataRow dr in dt.Rows)
    //    {
    //        string disid = Convert.ToString(dr["id"]);
    //        string turename = Convert.ToString(dr["disname"]);
    //        this.ddldisname.Items.Insert(i, new ListItem(turename, disid));
    //        i++;
    //    }
    //}

    /// <summary>
    /// 查询录入明细
    /// </summary>
    public void Bind()
    {
        //查询录入明细
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        //查询账单收款补录
        strwhere += " and PreType=8";
        //有效数据显示
        // strwhere += " and IsEnabled = 1";
        //审核状态是已审的
        //strwhere += " and AuditState = 2";
        //付款状态是成功的
        strwhere += " and Start=1";

        //所属企业
        strwhere += " and CompID=" + this.CompID;

        //int disId = Convert.ToInt32(Request.QueryString["keyId"]);
        //if (disId != 0)
        //{
        //    strwhere += " and DisID=" + disId + "";
        //}

        if (ViewState["strwhere"] != null)
        {
            strwhere += ViewState["strwhere"].ToString();
        }
        if (this.txtPager.Value.Trim().ToString() != "")
        {
            if (this.txtPager.Value.Trim().Length >= 5)
            {
                Pager.PageSize      = 100;
                this.txtPager.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
            }
        }

        List <Hi.Model.PAY_PrePayment> pay = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);

        this.rptPay.DataSource = pay;
        this.rptPay.DataBind();


        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #8
0
    public void Bind()
    {
        Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(KeyID);
        if (prepayM == null)
        {
            JScript.AlertMethod(this, "该记录无效!", JScript.IconOption.错误, "function (){ location.replace('" + ("PrePayList.aspx") + "'); }");
            return;
        }
        //支付金额小于0,直接支付失败
        if (prepayM.price <= 0)
        {
            Response.Redirect("Error.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
            return;
        }


        if (prepayM.Start == 1)
        {
            Response.Redirect("Error.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
            return;
        }
        this.hidKeyID.Value       = Convert.ToString(KeyID);
        this.lblOrderNO.InnerText = prepayM.guid; // KeyID.ToString();
        this.lblPrice.InnerText   = prepayM.price.ToString("0.00");;

        string username = this.UserName;
        string strWhere = string.Empty;

        if (this.DisID != 0)
        {
            strWhere += " DisID = '" + this.DisID + "' ";
        }
        else
        {
            JScript.AlertMsgOne(this, "操作员没有对应的代理商!", JScript.IconOption.错误);
            return;
        }
        strWhere += " and Start = 1 and vdef6 = 0 and isnull(dr,0)=0";
        List <Hi.Model.PAY_FastPayMent> fastList = new Hi.BLL.PAY_FastPayMent().GetList("", strWhere, "");

        this.rptQpay.DataSource = fastList;
        this.rptQpay.DataBind();
        List <Hi.Model.PAY_BankInfo> BankL = new Hi.BLL.PAY_BankInfo().GetList("", " vdef1=0", "");

        this.rptOtherBank.DataSource = BankL;
        this.rptOtherBank.DataBind();
    }
Example #9
0
    /// <summary>
    /// 代理商列表显示
    /// </summary>
    public void Bind()
    {
        //查询录入明细
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        strwhere += " and Start=1 and PreType=1";

        if (this.DisID != 0)
        {
            strwhere += " and DisID=" + this.DisID + "";
        }
        if (ViewState["sqldate"] != null)
        {
            strwhere += ViewState["sqldate"].ToString();
        }
        if (this.txtPager.Value.Trim().ToString() != "")
        {
            if (this.txtPager.Value.Trim().Length >= 5)
            {
                Pager.PageSize      = 100;
                this.txtPager.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
            }
        }
        //if (this.txtArriveDate.Value.Trim() == "" && this.txtArriveDate1.Value.Trim() == "")
        //{
        //    strwhere += " and CreatDate>='" + DateTime.Now.AddDays(1 - DateTime.Now.Day).ToShortDateString() + " 0:0:0' ";
        //}
        List <Hi.Model.PAY_PrePayment> pay = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);
        List <Hi.Model.PAY_PrePayment> p   = new Hi.BLL.PAY_PrePayment().GetList("", " Start=1 and PreType=1 and disid=" + this.DisID + Where(), "");

        for (int i = 0; i < p.Count; i++)
        {
            ta += p[i].price;
        }
        this.rptOrder.DataSource = pay;
        this.rptOrder.DataBind();


        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #10
0
    /// <summary>
    /// 根据不同的状态,显示不同的操作按钮
    /// </summary>
    /// <param name="Ostate"></param>
    /// <param name="id"></param>
    /// <returns></returns>
    public string Getmessage(int Ostate, int id, int paystate)
    {
        string str = string.Empty;

        if (paystate != 2)
        {
            str = string.Format("<a href=\'javascript:void(0)\' onclick=\'pay({0},{1})\' class=\"tablelinkQx\">订单补录</a>", id, Ostate);
        }
        else
        {
            DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("ID", "pay_prepayment", "PreType=7 and OrderID=" + id);
            if (dt.Rows.Count > 0)
            {
                id = Convert.ToInt32(dt.Rows[0][0]);
            }
            str += string.Format("<a href=\'javascript:void(0)\' onclick=\'goPreInfo({0})\' class=\"tablelinkQx\">补录详情</a>", id);
        }
        //}
        return(str);
    }
Example #11
0
    public void Bind()
    {
        decimal price = 0;

        Hi.Model.DIS_Order     orderM = new Hi.BLL.DIS_Order().GetModel(KeyID);
        Hi.Model.PAY_Payment   payM   = new Hi.BLL.PAY_Payment().GetModel(Pid);
        Hi.Model.PAY_Financing FinM   = new Hi.BLL.PAY_Financing().GetModel(Fid);
        if (payM != null)
        {
            price += payM.PayPrice;
        }
        Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(PPid);
        if (prepayM != null)
        {
            price += prepayM.price * -1;
        }
        if (FinM != null)
        {
            price += FinM.AclAmt;
        }
        this.PayedAmount.InnerHtml = price.ToString("0.00");
    }
Example #12
0
    /// <summary>
    /// 绑定数据
    /// </summary>
    public void Bind()
    {
        //查询录入明细
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        //查询全部 转账汇款的记录
        strwhere += " and PreType=1";
        //付款状态是成功的
        strwhere += " and Start=1";
        //付款审核状态是已审的
        strwhere += " and AuditState=2";
        //是否已结算
        strwhere += " and (vdef2  is null or vdef2='') ";

        //所属企业
        strwhere += " and CompID=" + CompID;

        //int disId = Convert.ToInt32(Request.QueryString["keyId"]);
        //if (disId != 0)
        //{
        //    strwhere += " and DisID=" + disId + "";
        //}

        if (ViewState["strwhere"] != null)
        {
            strwhere += ViewState["strwhere"].ToString();
        }
        if (this.txtPager.Value.Trim().ToString() != "")
        {
            Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
        }

        List <Hi.Model.PAY_PrePayment> pay = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);

        this.rptOrder.DataSource = pay;
        this.rptOrder.DataBind();
    }
Example #13
0
    /// <summary>
    /// 代理商列表显示
    /// </summary>
    public void Bind()
    {
        //查询录入明细
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        //查询全部手动录入冲正
        //strwhere += " and PreType=3";
        //有效数据显示
        // strwhere += " and IsEnabled = 1";
        //审核状态是已审的
        //strwhere += " and AuditState = 2";
        //付款状态是成功的
        strwhere += " and Start=1";

        int disId = this.DisID;

        if (disId != 0)
        {
            strwhere += " and PreType in (1,2,3,4,5)  and DisID=" + disId + "";
        }
        if (ViewState["strwhere"] != null)
        {
            strwhere += ViewState["strwhere"].ToString();
        }

        Pager.PageSize = 10;

        List <Hi.Model.PAY_PrePayment> pay = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);

        this.rptDis.DataSource = pay;
        this.rptDis.DataBind();


        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #14
0
    /// <summary>
    /// 查询转账汇款记录
    /// </summary>
    public void Bind()
    {
        //查询转账汇款记录
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        //查询需要审核转账汇款记录
        // strwhere += " and PreType=1";
        strwhere += " and AuditState=0";
        strwhere += " and Start=1 and CompID=" + CompID;

        if (ViewState["strwhere"] != null)
        {
            strwhere += ViewState["strwhere"].ToString();
        }
        if (this.txtPager.Value.Trim().ToString() != "")
        {
            if (this.txtPager.Value.Trim().Length >= 5)
            {
                Pager.PageSize      = 100;
                this.txtPager.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
            }
        }
        List <Hi.Model.PAY_PrePayment> Exa = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);

        this.rptExa.DataSource = Exa;
        this.rptExa.DataBind();

        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #15
0
    /// <summary>
    /// 绑定数据
    /// </summary>
    public void Bind()
    {
        int    pageCount = 0;
        int    Counts    = 0;
        string strwhere  = string.Empty;

        strwhere += " and Start=1 and PreType=1";
        if (ViewState["sqldate"] != null)
        {
            strwhere += ViewState["sqldate"].ToString();
        }
        if (this.txtPager.Value.Trim().ToString() != "")
        {
            if (this.txtPager.Value.Trim().Length >= 5)
            {
                Pager.PageSize      = 100;
                this.txtPager.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPager.Value.Trim().ToInt(0);
            }
        }
        //if (this.txtBCreateDate.Value.Trim() == "" && this.txtECreateDate.Value.Trim() == "")
        //{
        //    strwhere += " and CreatDate>='" + DateTime.Now.AddDays(1 - DateTime.Now.Day).ToShortDateString() + " 0:0:0' ";
        //}
        List <Hi.Model.PAY_PrePayment> pay = new Hi.BLL.PAY_PrePayment().GetList(Pager.PageSize, Pager.CurrentPageIndex, "CreatDate", true, strwhere, out pageCount, out Counts);

        this.rptOrder.DataSource = pay;
        this.rptOrder.DataBind();


        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Example #16
0
    /// <summary>
    /// 银行卡绑定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //声明变量
        string AccountName = string.Empty;
        string bankcode    = string.Empty;
        string bankAddress = string.Empty;
        string bankPrivate = string.Empty;
        string bankCity    = string.Empty;
        int    Isno        = 0;
        string remark      = string.Empty;
        string county      = string.Empty; //开会所在区县
        int    BankId      = 0;            //银行Id
        int    type        = 0;            //账户类型

        //收集数据
        AccountName = Common.NoHTML(this.txtDisUser.Value.Trim());//账户名称
        bankcode    = Common.NoHTML(this.txtbankcode.Value.Replace(" ", ""));
        bankAddress = Common.NoHTML(this.txtbankAddress.Value.Trim());
        bankPrivate = Common.NoHTML(this.hidProvince.Value.Trim());
        bankCity    = Common.NoHTML(this.hidCity.Value.Trim());
        county      = Common.NoHTML(this.hidArea.Value.Trim());
        Isno        = Convert.ToInt32(this.chkIsno.Checked == true ? 1 : 0);

        int is_no = Convert.ToInt32(this.hid_isno.Value);

        if (is_no == 1)
        {
            int success = new Hi.BLL.PAY_PrePayment().Upisno();
        }

        remark = Common.NoHTML(this.txtRemark.Value.Trim());
        BankId = Convert.ToInt32(this.ddlbank.Value);
        type   = Convert.ToInt32(this.ddltype.Value);

        //实例化对象实体
        Hi.Model.SYS_PaymentBank pbModel = new Hi.Model.SYS_PaymentBank();

        // Paid = Convert.ToInt32(Request.QueryString["paid"]);
        //pbModel.paymentAccountID = Paid;
        pbModel.BankID      = BankId;
        pbModel.AccountName = AccountName;
        pbModel.bankcode    = bankcode;
        pbModel.bankAddress = bankAddress;
        pbModel.bankPrivate = bankPrivate;
        pbModel.bankCity    = bankCity;
        pbModel.Isno        = Isno;
        pbModel.Remark      = remark;
        pbModel.CreateDate  = DateTime.Now;
        pbModel.CreateUser  = UserID;
        pbModel.dr          = 0;
        pbModel.modifyuser  = UserID;
        pbModel.ts          = DateTime.Now;
        pbModel.vdef1       = county;
        pbModel.Start       = 1;

        // pbModel.vdef4 = Common.NoHTML(this.txtphone.InnerText);
        // pbModel.vdef5 = Common.NoHTML(this.txtphpcode.Value);
        pbModel.type  = type;
        pbModel.vdef2 = Common.NoHTML(this.SltPesontype.Value);
        pbModel.vdef3 = Common.NoHTML(this.txtpesoncode.Value);
        if (KeyID > 0)
        {
            pbModel.ID = KeyID;
            bool result = new Hi.BLL.SYS_PaymentBank().Update(pbModel);

            if (result)
            {
                //判断平台是否有默认账户
                List <Hi.Model.SYS_PaymentBank> Sysl = new Hi.BLL.SYS_PaymentBank().GetList("", " Isno=1", "");
                int num = Sysl.Count;
                if (num == 0)
                {
                    JScript.AlertMsg(this, "平台最好有一个,默认第一收款账户,请检查!", "PaybankInfo.aspx?paid=" + Paid + "&KeyID=" + KeyID);
                }
                else
                {
                    Response.Redirect("PaybankInfo.aspx?paid=" + Paid + "&KeyID=" + KeyID);
                }
            }
        }
        else
        {
            int succes = new Hi.BLL.SYS_PaymentBank().Add(pbModel);
            if (succes > 0)//银行账户保存成功后,进行绑定代理商操作
            {
                //判断平台是否有默认账户
                List <Hi.Model.SYS_PaymentBank> Sysl = new Hi.BLL.SYS_PaymentBank().GetList("", " Isno=1", "");
                int num = Sysl.Count;
                if (num == 0)
                {
                    JScript.AlertMsg(this, "平台最好有一个,默认第一收款账户,请检查!", "PaybankInfo.aspx?paid=" + Paid + "&KeyID=" + succes);
                }
                else
                {
                    Response.Redirect("PaybankInfo.aspx?paid=" + Paid + "&KeyID=" + succes);
                }
            }
        }
    }
Example #17
0
    /// <summary>
    /// 订单信息
    /// </summary>
    public void databind()
    {
        if (KeyID != 0)
        {
            //判断改该条数据代理商是否有操作权限
            if (!Common.PageDisOperable("Order", KeyID, DisID))
            {
                Response.Redirect("../NoOperable.aspx");
                return;
            }
            hidOrderID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);

            string where = "and isnull(o.dr,0)=0 and o.otype<>9 and o.DisID=" + DisID + " and o.ID= " + KeyID;

            DataTable dt = new Hi.BLL.DIS_Order().GetList("", where);

            if (dt != null && dt.Rows.Count > 0)
            {
                //再次购买
                buyagain.Visible = false;
                //订单修改
                modifyorder.Visible = false;
                //订单作废
                ordervoid.Visible = false;
                //申请退货
                //orderReturn.Visible = false;

                Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", dt.Rows[0]["CompID"].ToString().ToInt(0));

                IsShow = OrderInfoType.rdoOrderAudit("订单明细是否显示店铺商品", 0).ToInt(0);
                IsInve = OrderInfoType.rdoOrderAudit("商品是否启用库存", dt.Rows[0]["CompID"].ToString().ToInt(0)).ToInt(0);

                hidDigits.Value = Digits;

                isbate = OrderInfoType.rdoOrderAudit("订单支付返利是否启用", dt.Rows[0]["CompID"].ToString().ToInt(0)).ToInt(0);
                if (isbate == 0)
                {
                    if (dt.Rows[0]["bateAmount"].ToString() == "" || dt.Rows[0]["bateAmount"].ToString() == "0.00")
                    {
                        this.trbate.Visible = false;
                        this.rebate.Visible = false;
                    }
                }

                // 订单编号
                lblReceiptNo.InnerText  = dt.Rows[0]["ReceiptNo"].ToString();
                lblCreateDate.InnerText = dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblOstate.InnerText     = OrderType.GetOState(dt.Rows[0]["OState"].ToString(), dt.Rows[0]["IsOutState"].ToString());
                hidOstate.Value         = dt.Rows[0]["OState"].ToString();

                lblCompID.InnerText = Common.Getcom(dt.Rows[0]["CompID"].ToString().ToInt(0), "CompName");
                orderCompId         = Convert.ToString(dt.Rows[0]["CompID"]);

                hidIsOutstate.Value = dt.Rows[0]["IsOutState"].ToString();

                OState       = dt.Rows[0]["OState"].ToString().ToInt(0);
                IsOutState   = dt.Rows[0]["IsOutState"].ToString().ToInt(0);
                payState     = dt.Rows[0]["PayState"].ToString().ToInt(0);
                ReturnState  = dt.Rows[0]["ReturnState"].ToString().ToInt(0);
                hidDts.Value = dt.Rows[0]["ts"].ToString();

                //订单流程
                lblTotalAmount.InnerText = dt.Rows[0]["TotalAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["TotalAmount"].ToString().ToDecimal().ToString("N");
                lblProAmount.InnerText   = dt.Rows[0]["ProAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["ProAmount"].ToString().ToDecimal().ToString("N");

                lblbateAmount.InnerText = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("N");
                lblbate.InnerText       = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("N");

                lblPostFee.InnerText     = dt.Rows[0]["PostFee"].ToString() == "" ? "0.00" : dt.Rows[0]["PostFee"].ToString().ToDecimal().ToString("0.00");
                lblAuditAmount.InnerText = dt.Rows[0]["AuditAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["AuditAmount"].ToString().ToDecimal().ToString("N");

                //下单信息
                lblArriveDate.InnerText = dt.Rows[0]["ArriveDate"].ToString() == "" ? "" : dt.Rows[0]["ArriveDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblGiveMode.InnerText   = dt.Rows[0]["GiveMode"].ToString();
                iRemark.InnerText       = dt.Rows[0]["Remark"].ToString();

                //收货地址
                lblPrincipal.InnerText = dt.Rows[0]["Principal"].ToString();
                lblPhone.InnerText     = dt.Rows[0]["Phone"].ToString();
                lblAddress.InnerText   = dt.Rows[0]["Address"].ToString();
                hidAddrID.Value        = dt.Rows[0]["AddrID"].ToString();

                //开票信息
                if (dt.Rows[0]["IsOBill"].ToString().ToInt(0) > 0)
                {
                    hidDisAccID.Value = dt.Rows[0]["DisAccID"].ToString();
                    hidval.Value      = dt.Rows[0]["IsOBill"].ToString();
                    string Billing = string.Empty;
                    Billing += "发票抬头:<label id=\"lblRise\" runat=\"server\">" + dt.Rows[0]["Rise"].ToString() + "</label>";
                    Billing += ",发票内容:<label id=\"lblContent\" runat=\"server\">" + dt.Rows[0]["Content"].ToString() + "</label>";
                    if (dt.Rows[0]["IsOBill"].ToString().ToInt(0) == 2)
                    {
                        Billing += ",开户银行:<label id=\"lblOBank\" runat=\"server\">" + dt.Rows[0]["OBank"].ToString() + "</label>";
                        Billing += ",开户账户:<label id=\"lblOAccount\" runat=\"server\">" + dt.Rows[0]["OAccount"].ToString() + "</label>";
                        Billing += ",纳税人登记号:<label id=\"lblTRNumber\" runat=\"server\">" + dt.Rows[0]["TRNumber"].ToString() + "</label>";
                    }
                    else
                    {
                        Billing += ",纳税人登记号:<label id=\"lblTRNumber\" runat=\"server\">" + dt.Rows[0]["TRNumber"].ToString() + "</label>";
                    }
                    iInvoice.InnerHtml = Billing;

                    //lblRise.InnerText = dt.Rows[0]["Rise"].ToString();
                    //lblContent.InnerText = dt.Rows[0]["Content"].ToString();
                    //lblOBank.InnerText = dt.Rows[0]["OBank"].ToString();
                    //lblOAccount.InnerText = dt.Rows[0]["OAccount"].ToString();
                    //lblTRNumber.InnerText = dt.Rows[0]["TRNumber"].ToString();
                }
                else
                {
                    this.iInvoice.InnerHtml = "不开发票";
                }

                //发票信息
                lblBillNo.InnerText  = dt.Rows[0]["BillNo"].ToString();
                lblIsBill.InnerText  = dt.Rows[0]["IsBill"].ToString() == "1" ? "是" : "否";
                this.hidisBill.Value = dt.Rows[0]["IsBill"].ToString();


                string msg  = string.Empty;
                bool   flag = Common.FCan(dt.Rows[0]["DisID"].ToString(), "1", out msg);
                if (flag)
                {
                    this.lblmsg.InnerText = msg;
                }

                decimal nopayAmount = OrderInfoType.GetSumAmount(dt.Rows[0]["DisID"].ToString(), dt.Rows[0]["CompID"].ToString(), KeyID);
                if (nopayAmount > 0)
                {
                    string promptmsg = "订单待支付金额为¥" + nopayAmount.ToString("0.00") + ",请尽快支付";
                    this.lblPrompt.InnerText = promptmsg;
                }
                else
                {
                    this.lblPrompt.Visible = false;
                }


                #region  订单支付信息

                TotalAmount = Convert.ToDecimal(dt.Rows[0]["AuditAmount"]).ToString("0.00");
                PayedAmount = Convert.ToDecimal(dt.Rows[0]["PayedAmount"]).ToString("0.00");

                //订单已支付不显示支付按钮(未审核、未支付完成)
                if (Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.未提交 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.待审核 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.待审核 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.已退货 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.已作废 || (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"]) == 0))
                {
                    btn_pay.Visible = false;
                }
                paymoney = (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"])).ToString("0.00");

                //加密keyId
                desKeyID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);

                //绑定支付流水信息
                DataTable paytable = new Hi.BLL.PAY_PrePayment().GetPayedItem(KeyID);
                rptmessage.DataSource = paytable;
                rptmessage.DataBind();

                //初始值加载
                txtArriveDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
                DataTable dtpayment = new Hi.BLL.PAY_PrePayment().GetDate(" top 1   CreateDate, payName ,paycode ,paybank", "pay_payment", " DisID=" + DisID + " and vdef3=5 order by  CreateDate desc");
                foreach (DataRow dr in dtpayment.Rows)
                {
                    bankname.Value = Convert.ToString(dr["payName"]);
                    bankcode.Value = Convert.ToString(dr["paycode"]);
                    bank.Value     = Convert.ToString(dr["paybank"]);
                }


                //附件
                //if (dt.Rows[0]["Atta"].ToString() != "")
                //{
                //    StringBuilder li = new StringBuilder();
                //    string[] atta = dt.Rows[0]["Atta"].ToString().Split(new string[] { "$$&&" }, StringSplitOptions.RemoveEmptyEntries);
                //    if (atta.Length > 0)
                //    {
                //        foreach (var item in atta)
                //        {
                //            li.AppendFormat("<li> <a href=\"javascript:;\" class=\"name\">{0}</a><a href=\"javascript:;\"  class=\"bule del\" orderid=\"{1}\">删除</a><a href=\"javascript:;\" class=\"bule\">下载</a></li>", item, KeyID);

                //        }
                //    }
                // this.payulfile.InnerHtml = li.ToString();
                //}
                #endregion


                //附件
                if (dt.Rows[0]["Atta"].ToString() != "")
                {
                    StringBuilder li   = new StringBuilder();
                    string[]      atta = dt.Rows[0]["Atta"].ToString().Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (atta.Length > 0)
                    {
                        foreach (var item in atta)
                        {
                            string[] att = item.Split(new string[] { "^^" }, StringSplitOptions.RemoveEmptyEntries);

                            if (att.Length > 1)
                            {
                                li.AppendFormat("<li> <a href=\"{2}\" target=\"_blank\" class=\"name\">{0}(大小:{4}KB)</a><a href=\"javascript:;\"  class=\"bule del\" tip=\"{3}\" orderid=\"{1}\">删除</a><a href=\"{2}\" target=\"_blank\" class=\"bule\">下载</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                            }
                        }
                    }
                    ulAtta.InnerHtml     = li.ToString();
                    this.hrOrderFj.Value = dt.Rows[0]["Atta"].ToString();
                }

                #region 订单明细

                //订单所有商品明细
                DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + KeyID);
                if (l != null && l.Rows.Count > 0)
                {
                    rptOrderD.DataSource = l;
                    rptOrderD.DataBind();

                    //待发货商品
                    DataTable lno = SelectGoodsInfo.SreeenDataTable(l, "isnull(IsOut,0)=0"); //l.Select(string.Format("IsOut={0}", 0));
                    if (lno != null && lno.Rows.Count > 0)
                    {
                        rptIsout.DataSource = lno;
                        rptIsout.DataBind();
                    }

                    //已发货商品
                    List <Hi.Model.DIS_OrderOutDetail> loud = new Hi.BLL.DIS_OrderOutDetail().GetList("", " isnull(dr,0)=0 and OrderID=" + KeyID, "");
                    //发货单 and o.IsAudit<>3
                    DataTable lo = new Hi.BLL.DIS_OrderOut().GetList("", " isnull(o.dr,0)=0 and o.OrderID=" + KeyID + " Order by o.IsAudit");

                    if (loud != null && loud.Count > 0)
                    {
                        //outbind(lo, l, loud);
                        outGoods.InnerHtml = SelectGoodsInfo.outbind(lo, l, loud, Digits, 0);
                    }

                    #region 流程时间控件

                    if (lo != null && lo.Rows.Count > 0)
                    {
                        if (((int)Enums.OrderState.已发货 <= OState || OState == (int)Enums.OrderState.退货处理) && (IsOutState == 3 || IsOutState == 4))
                        {
                            //订单发货时间
                            DataRow[] sendlo = lo.Select("IsAudit<>3");
                            DataRow[] dv     = sendlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dv.Length > 0)
                            {
                                sendde = dv[0]["SendDate"].ToString() != "" ? dv[0]["SendDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }

                        if ((int)Enums.OrderState.已到货 <= OState || OState == (int)Enums.OrderState.退货处理)
                        {
                            //订单签收时间
                            DataRow[] signlo = lo.Select("IsAudit<>3 and IsSign=1");
                            DataRow[] dr     = signlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dr.Length > 0)
                            {
                                signde = dr[0]["SignDate"].ToString() != "" ? dr[0]["SignDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }
                    }
                    #endregion
                }
                #endregion

                #region 流程时间控件
                //订单流程时间显示
                //订单提交时间
                CreateDate = dt.Rows[0]["CreateDate"].ToString() != "" ? dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";

                //订单审核时间
                AuditDate = dt.Rows[0]["AuditDate"].ToString() != "" ? dt.Rows[0]["AuditDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                #endregion 流程时间控件

                #region 订单操作按钮

                switch (OState)
                {
                case (int)Enums.OrderState.待审核:
                    modifyorder.Visible = true;
                    buyagain.Visible    = true;
                    ordervoid.Visible   = true;
                    break;

                case (int)Enums.OrderState.已审:
                    //订单审核前,可以修改订单。
                    buyagain.Visible = true;
                    break;

                case (int)Enums.OrderState.退货处理:
                    //orderReturn.Visible = false;
                    buyagain.Visible = true;
                    btn_pay.Visible  = false;
                    fulfil           = signde;
                    break;

                case (int)Enums.OrderState.已发货:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    break;

                case (int)Enums.OrderState.已到货:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    if (dt.Rows[0]["CreateDate"].ToString().ToDateTime() > DateTime.Now.AddMonths(-3))
                    {
                        //三个月以内的订单可退货
                        //if (ReturnState < (int)Enums.ReturnState.申请退货)
                        //orderReturn.Visible = true;
                    }
                    if (ReturnState >= (int)Enums.ReturnState.申请退货)
                    {
                        btn_pay.Visible = false;
                    }
                    if (sendde == "" && signde == "" && AuditDate != "")
                    {
                        fulfil = AuditDate;
                    }
                    else if (AuditDate.ToString() == "")
                    {
                        fulfil = CreateDate;
                    }
                    else
                    {
                        fulfil = signde == "" ? sendde : signde;
                    }
                    break;

                case (int)Enums.OrderState.已作废:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    fulfil = Convert.ToDateTime(dt.Rows[0]["ts"]).ToString("yyyy-MM-dd HH:mm");
                    break;

                case (int)Enums.OrderState.已退货:
                    buyagain.Visible = true;
                    btn_pay.Visible  = false;
                    fulfil           = signde;
                    break;

                default:
                    break;
                }

                #endregion

                //订单修改,再次购买
                if (!Common.HasRight(this.CompID, this.UserID, "1010", this.DisID))
                {
                    this.buyagain.Visible    = false;
                    this.modifyorder.Visible = false;
                }
                //订单作废
                if (!Common.HasRight(this.CompID, this.UserID, "2012", this.DisID))
                {
                    this.ordervoid.Visible = false;
                }
                //在线支付
                if (!Common.HasRight(this.CompID, this.UserID, "2014", this.DisID))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "btn_pay_xs", "<script> $('#btn_pay_xs').hide();</script>");
                }

                //线下支付
                if (!Common.HasRight(this.CompID, this.UserID, "2015", this.DisID))
                {
                    this.btn_pay_xx.Visible = false;
                }
                //申请退货
                //if (!Common.HasRight(this.CompID, this.UserID, "2311", this.DisID))
                //this.orderReturn.Visible = false;
                //确认收货
                if (!Common.HasRight(this.CompID, this.UserID, "2013", this.DisID))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "btnsign", "<script> $('.btnsign,.btnsigni').hide();</script>");
                }
            }
        }
        else
        {
            Response.Redirect("../NoOperable.aspx");
            return;
        }
    }
Example #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //this.lblMsg.InnerText = Request["msg"];
        LogManager.LogFielPrefix = "jsnx";
        LogManager.LogPath       = "C:/requestpag/";
        LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "进入回调页面");
        SortedDictionary <string, string> sPara = GetRequestPost();

        try
        {
            if (sPara == null || sPara.Count <= 0)
            {
                Response.Write("无通知参数");
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:无通知参数");
                return;
            }
            Notify aliNotify    = new Notify();
            bool   verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
            if (!verifyResult)//验证失败
            {
                Response.Write("fail");
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:验证失败");
                return;
            }

            //企业订单号
            string out_trade_no = Common.NoHTML(Request.Form["out_trade_no"]);

            //支付宝交易号
            string trade_no = Common.NoHTML(Request.Form["trade_no"]);

            //交易状态
            string trade_status = Common.NoHTML(Request.Form["trade_status"]);

            decimal prepayPrice = 0;
            string  guid        = "";
            int     orderid     = 0;
            Hi.Model.PAY_RegisterLog        regM = new Hi.Model.PAY_RegisterLog();
            List <Hi.Model.PAY_RegisterLog> regL = new Hi.BLL.PAY_RegisterLog().GetList("", " Ordercode = '" + out_trade_no + "'", "");
            if (regL == null || regL.Count <= 0)
            {
                Response.Write("找不到" + out_trade_no);
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:找不到" + out_trade_no);
                return;
            }
            regM = regL[0];
            try
            {
                regM.Start         = trade_status;
                regM.ResultMessage = trade_no;
                new Hi.BLL.PAY_RegisterLog().Update(regM);
            }
            catch { }
            guid    = regM.number;
            orderid = regM.OrderId;
            Hi.Model.DIS_Order          orderModel = new Hi.BLL.DIS_Order().GetModel(orderid);
            Hi.Model.PAY_Payment        payM       = new Hi.Model.PAY_Payment();
            List <Hi.Model.PAY_Payment> payL       = new Hi.BLL.PAY_Payment().GetList("", " guid = '" + guid + "' ", "");
            if (payL == null || payL.Count <= 0)
            {
                Response.Write("找不到" + out_trade_no);
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:找不到" + out_trade_no);
                return;
            }
            payM = payL[0];
            if (payM.IsAudit == 1)
            {
                Response.Write("success");//请不要修改或删除,输出success后,支付宝将不再发送通知
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\n支付成功\r\n支付订单号:" + out_trade_no);
                return;
            }
            if (trade_status != "TRADE_SUCCESS")
            {
                Response.Write(GetTradeStatusByName(trade_status));
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:" + GetTradeStatusByName(trade_status) + "\r\n支付订单号:" + out_trade_no);
                return;
            }
            Hi.Model.PAY_PrePayment        prepayM = new Hi.Model.PAY_PrePayment();
            List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", " vdef4 = '" + payM.ID + "' ", "");
            if (prepayL != null && prepayL.Count > 0)
            {
                prepayM     = prepayL[0];
                prepayPrice = prepayM.price * -1;
            }

            int           order  = 0;
            int           prepay = 0;
            int           pay    = 0;
            SqlConnection con    = new SqlConnection(LocalSqlServer);
            con.Open();
            SqlTransaction sqlTrans = con.BeginTransaction();
            try
            {
                order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderid, payM.PayPrice + prepayPrice, sqlTrans);
                pay   = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans);
                if (prepayPrice > 0)
                {
                    prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans);
                }
                else
                {
                    prepay = 1;
                }
                sqlTrans.Commit();
            }
            catch (Exception ex)
            {
                Response.Write("Error");
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:" + ex.Message + "\r\n支付订单号:" + out_trade_no);
                order  = 0;
                prepay = 0;
                pay    = 0;
                sqlTrans.Rollback();
            }
            finally
            {
                con.Close();
            }
            if (order <= 0 || prepay <= 0 || pay <= 0)
            {
                Response.Write("Error");
                LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:支付成功,修改状态失败,等待下次页面通知\r\n支付订单号:" + out_trade_no);
                return;
            }

            try
            {
                new Common().GetWxService("2", orderModel.ID.ToString(), "1");
                if (orderModel.Otype != 9)
                {
                    OrderInfoType.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + payM.PayPrice), "订单支付", "", orderModel.CreateUserID);
                }
            }
            catch { }
            if (orderModel.Otype == (int)Enums.OType.推送账单)
            {
                Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "账单支付", "支付:" + (prepayPrice + payM.PayPrice).ToString("0.00") + "元(支付宝支付)", payM.CreateUserID.ToString());
            }
            else
            {
                Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "订单支付", "支付:" + (prepayPrice + payM.PayPrice).ToString("0.00") + "元(支付宝支付)", payM.CreateUserID.ToString());
            }

            Response.Write("success");  //请不要修改或删除,输出success后,支付宝将不再发送通知
            LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\n支付成功\r\n支付订单号:" + out_trade_no);
            return;
        }
        catch (Exception ex)
        {
            LogManager.LogFielPrefix = "requestpag";
            LogManager.LogPath       = "C:/requestpag/";
            LogManager.WriteLog(LogFile.Error.ToString(), "Error:" + ex.Message + "\r\n");
            Response.Write(ex.Message);
            return;
        }
        finally
        {
            Response.End();
        }
    }
Example #19
0
    public void Tx1372()
    {
        LogManager.LogFielPrefix = "tx1372";
        LogManager.LogPath       = "D:/Tx1372Order_log/";
        LogManager.WriteLog(LogFile.Trace.ToString(), DateTime.Now + "进入Tx372程序\r");
        string    LocalSqlServer = SqlHelper.LocalSqlServer;
        DataTable dt             = new Hi.BLL.PAY_PrePayment().GetDate("guid,id,OrderID", "pay_payment", "  verifystatus=40 and status =10 and IsAudit =2 ");

        foreach (DataRow dr in dt.Rows)
        {
            string number    = Convert.ToString(dr["guid"]);   //支付交易流水号
            int    paymentid = Convert.ToInt32(dr["id"]);      //支付表id
            int    Orderid   = Convert.ToInt32(dr["OrderID"]); //支付表关联ID

            string configPath = WebConfigurationManager.AppSettings["payment.config.path"];
            PaymentEnvironment.Initialize(configPath);
            string institutionID = WebConfigurationManager.AppSettings["PayOrgCode"];//机构号码

            Tx1372Request tx1372 = new Tx1372Request();
            tx1372.setInstitutionID(institutionID);
            tx1372.setPaymentNo(number);
            tx1372.process();
            TxMessenger    txMessenger    = new TxMessenger();
            String[]       respMsg        = txMessenger.send(tx1372.getRequestMessage(), tx1372.getRequestSignature());
            Tx1372Response tx1372Response = new Tx1372Response(respMsg[0], respMsg[1]);
            //接口调用成功
            if ("2000".Equals(tx1372Response.getCode()))
            {
                LogManager.WriteLog(LogFile.Trace.ToString(), "流水号:" + number + "    状态:" + tx1372Response.getStatus() + "\r");
                //支付成功
                if (20 == tx1372Response.getStatus())
                {
                    //支付成功,修改状态
                    //企业钱包修改状态
                    int           order  = 0;
                    int           pay    = 0;
                    int           prepay = 0;
                    SqlConnection con    = new SqlConnection(LocalSqlServer);
                    con.Open();
                    SqlTransaction sqlTrans = con.BeginTransaction();
                    try
                    {
                        Hi.Model.PAY_Payment    paymentmodel    = new Hi.BLL.PAY_Payment().GetModel(paymentid);
                        Hi.Model.DIS_Order      ordermodel      = new Hi.BLL.DIS_Order().GetModel(Orderid);
                        Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.BLL.PAY_PrePayment().GetModel(Orderid);
                        if (ordermodel != null)                                                                                                                                                       //订单支付
                        {
                            order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, Orderid, paymentmodel.PayPrice - Convert.ToDecimal(paymentmodel.vdef5 == "" ? "0" : paymentmodel.vdef5), sqlTrans); //修改订单状态
                            pay   = new Hi.BLL.PAY_Payment().updatePayState(con, paymentid, sqlTrans);                                                                                                //修改支付表状态

                            if (order > 0 && pay > 0)
                            {
                                sqlTrans.Commit();
                            }
                            else
                            {
                                sqlTrans.Rollback();
                            }
                        }
                        else if (prepaymentmodel != null)//预付款充值
                        {
                            pay    = new Hi.BLL.PAY_Payment().updatePayState(con, paymentid, sqlTrans);
                            prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepaymentmodel.ID, sqlTrans);
                            if (pay > 0 && prepay > 0)
                            {
                                sqlTrans.Commit();
                            }
                            else
                            {
                                sqlTrans.Rollback();
                            }
                        }
                    }
                    catch
                    {
                        order = 0;
                        pay   = 0;
                        sqlTrans.Rollback();
                    }
                    finally
                    {
                        con.Close();
                    }
                }
                else if (30 == tx1372Response.getStatus())//支付失败
                {
                    Hi.Model.PAY_Payment payment = new Hi.BLL.PAY_Payment().GetModel(paymentid);
                    payment.status = 30;//支付失败
                    new Hi.BLL.PAY_Payment().Update(payment);

                    LogManager.WriteLog(LogFile.Trace.ToString(), "失败:" + tx1372Response.getStatus() + "\r");
                }
            }
        }
    }
Example #20
0
    /// <summary>
    /// 清算手续费
    /// </summary>
    /// <param name="sxf">sxf金额</param>
    /// <returns></returns>
    public bool JS_sxfWay(int ordID, string ReceiptNo, string guid, int compID, int paymentid, long price)
    {
        bool fal = false;
        //-----银行信息
        string orgcode              = string.Empty;  //机构代码
        int    accountType          = 0;             //帐号类型
        string paymentaccountname   = string.Empty;  //账户名称
        string paymentaccountnumber = string.Empty;  //账户号码
        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;         //开会所在市
        string remark        = "手续费清算-" + ReceiptNo; //

        int paylogID = 0;                            //记录日志Id

        //结算接口日志表
        Hi.Model.PAY_PayLog paylogmodel = new Hi.Model.PAY_PayLog();
        Hi.BLL.PAY_PayLog   paylogbll   = new Hi.BLL.PAY_PayLog();
        //获取平台银行收款账户
        DataTable dt_bank = new Hi.BLL.PAY_PrePayment().GetDate(@"'001520' as  OrgCode,'' as payName,'' as PayCode,SYS_PaymentBank.type,
 SYS_PaymentBank.BankID,SYS_PaymentBank.AccountName,SYS_PaymentBank.bankcode
 ,SYS_PaymentBank.bankAddress,SYS_PaymentBank.bankprivate,SYS_PaymentBank.bankcity", "SYS_PaymentBank", "  SYS_PaymentBank.Isno=1  and SYS_PaymentBank.dr=0");

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


            //先插入日志表,
            paylogmodel.OrderId     = ordID;
            paylogmodel.Ordercode   = ReceiptNo;
            paylogmodel.number      = guid + "_sxf";
            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  = 0;
            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 + "_sxf");
                    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();

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

                    if ("2000".Equals(tx134xResponse.getCode()))
                    {
                        //手续费收取成功,修改标记手续费清算状态 ,//手续费结算成功

                        int num = new Hi.BLL.PAY_PrePayment().Updatejsxf_no(ReceiptNo);
                        if (num > 0)
                        {
                            fal = true;
                        }
                    }
                    else
                    {
                        //清算出现问题,发送邮件通知
                        try
                        {
                            strs = "手续费结算失败:" + DateTime.Now.ToString() + "\r\n" + "错误流水号:" + ReceiptNo + "\r\n" + "企业ID:" + compID;
                            PayInfoType.SendFinsh(strs, ReceiptNo);
                        }
                        catch { }
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogFile.Trace.ToString(), "手续费结算接口出错:" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);
                }
            }
            else
            {
                LogManager.WriteLog(LogFile.Trace.ToString(), "手续费结算日志表插入出错:" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);
            }
        }
        else
        {
            //清算出现问题,发送邮件通知
            try
            {
                string mes = "<br>手续费结算失败,请维护收款帐号信息:" + DateTime.Now.ToString() + "<br>" + "错误流水号:" + ReceiptNo + "<br>" + "企业ID:" + compID;
                // PayInfoType.SendFinsh(mes, ReceiptNo);
            }
            catch { }
        }


        return(fal);
    }
Example #21
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
        }
    }
Example #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //ResultNotify resultNotify = new ResultNotify(this);
        //resultNotify.ProcessNotify();
        string resultFromWx = getPostStr();
        //设置支付参数
        var res = XDocument.Parse(resultFromWx);

        string return_code = res.Element("xml").Element("return_code").Value;

        string out_trade_no = res.Element("xml").Element("out_trade_no").Value;

        string result_code = res.Element("xml").Element("result_code").Value;

        string price = res.Element("xml").Element("total_fee").Value;

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //请在这里加上商户的业务逻辑程序代码
        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
        //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

        if (return_code == "SUCCESS" || result_code == "SUCCESS")
        {
            //判断该笔订单是否在商户网站中已经做过处理
            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
            //如果有做过处理,不执行商户的业务程序

            string strWhere2 = string.Empty;
            if (out_trade_no != "")
            {
                strWhere2 += " number = '" + out_trade_no + "'";
            }
            Hi.Model.PAY_RegisterLog        regM = new Hi.Model.PAY_RegisterLog();
            List <Hi.Model.PAY_RegisterLog> regL = new Hi.BLL.PAY_RegisterLog().GetList("", strWhere2, "");
            if (regL == null || regL.Count <= 0)
            {
                //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false);
                //return;
                Console.WriteLine("未找到对应的支付记录!");
            }
            regM = regL[0];
            string strWhere = string.Empty;
            if (out_trade_no != "")
            {
                strWhere += " guid = '" + out_trade_no + "'";
            }
            strWhere += " and isnull(dr,0)=0";
            Hi.Model.PAY_Payment        payM = new Hi.Model.PAY_Payment();
            List <Hi.Model.PAY_Payment> payL = new Hi.BLL.PAY_Payment().GetList("", strWhere, "");
            if (payL == null || payL.Count <= 0)
            {
                //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false);
                // return;
                Console.WriteLine("未找到对应的支付记录!");
            }
            payM = payL[0];

            payM.PayDate = DateTime.Now;
            payM.ts      = DateTime.Now;
            payM.status  = 0;      //trade_status == "TRADE_FINISHED" ? 80 : 90;
            new Hi.BLL.PAY_Payment().Update(payM);
            regM.Start = "";       // trade_status;
            new Hi.BLL.PAY_RegisterLog().Update(regM);
            if (payM.IsAudit == 2) //该支付记录未修改成功进入,修改成功就不进入,请不要重复操作
            {
                //!!!支付成功 !!!
                decimal prepayPrice = 0;

                //企业钱包充值
                Hi.Model.PAY_PrePayment prepayMnew = new Hi.Model.PAY_PrePayment();
                string strWhere3 = string.Empty;
                if (out_trade_no != "")
                {
                    strWhere3 += " ID = " + payM.OrderID;
                }
                strWhere3 += " and isnull(dr,0)=0";
                List <Hi.Model.PAY_PrePayment> plist = new Hi.BLL.PAY_PrePayment().GetList("", strWhere3, "");
                if (plist.Count > 0)
                {
                    prepayMnew = plist[0];
                }

                //订单
                Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(payM.OrderID);
                if (orderModel != null)
                {
                    string strWhere1 = string.Empty;
                    strWhere1 += " vdef4 = '" + payM.ID + "'";
                    strWhere1 += " and isnull(dr,0)=0";
                    Hi.Model.PAY_PrePayment        prepayM = new Hi.Model.PAY_PrePayment();
                    List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", strWhere1, "");
                    if (prepayL != null && prepayL.Count > 0)
                    {
                        prepayM     = prepayL[0];
                        prepayPrice = prepayM.price * -1;
                    }

                    int           order  = 0;
                    int           prepay = 0;
                    int           pay    = 0;
                    decimal       prices = Convert.ToDecimal(price);
                    SqlConnection con    = new SqlConnection(LocalSqlServer);
                    con.Open();
                    SqlTransaction sqlTrans = con.BeginTransaction();
                    try
                    {
                        order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderModel.ID, payM.PayPrice + prepayPrice - Convert.ToDecimal(payM.vdef5), sqlTrans);
                        pay   = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans);


                        if (prepayPrice > 0)
                        {
                            prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans);
                        }
                        else
                        {
                            prepay = 1;
                        }
                        sqlTrans.Commit();
                    }
                    catch
                    {
                        order  = 0;
                        prepay = 0;
                        pay    = 0;
                        sqlTrans.Rollback();
                    }
                    finally
                    {
                        con.Close();
                    }

                    if (order <= 0 || prepay <= 0 || pay <= 0)
                    {
                        Console.WriteLine("支付成功,但修改支付状态失败,请联系系统管理员,勿重复操作!");
                    }

                    try
                    {
                        //new Common().GetWxService("2", orderModel.ID.ToString(), "1");
                        if (orderModel.Otype != 9)
                        {
                            OrderInfoType.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + prices), "订单支付", "", orderModel.CreateUserID);
                        }
                    }
                    catch { }
                    if (orderModel.Otype == (int)Enums.OType.推送账单)
                    {
                        Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "账单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(微信支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString());
                    }
                    else
                    {
                        Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "订单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(微信支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString());
                    }

                    //微信和安卓消息推送
                    try
                    {
                        new Common().GetWxService("2", orderModel.ID.ToString(), "1", prepayPrice + prices);
                    }
                    catch { }


                    Response.Write("success");  //请不要修改或删除
                }//钱包充值
                else if (prepayMnew != null)
                {
                    int           prepay = 0;
                    int           pay    = 0;
                    SqlConnection con    = new SqlConnection(LocalSqlServer);
                    con.Open();
                    SqlTransaction sqlTrans = con.BeginTransaction();
                    try
                    {
                        pay    = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans);
                        prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayMnew.ID, sqlTrans);
                        sqlTrans.Commit();
                    }
                    catch
                    {
                        pay    = 0;
                        prepay = 0;
                        sqlTrans.Rollback();
                    }
                    finally
                    {
                        con.Close();
                    }
                }
                else
                {
                    //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到该支付订单!", false);
                    //return;

                    Console.WriteLine("未找到该支付记录!");
                }
            }
            else
            {
                Console.WriteLine("success");
            }


            Response.Write("success");
        }
        else//验证失败
        {
            Response.Write("fail");
        }
    }
Example #23
0
    ///<summary>
    ///获取钱包充值流水号
    ///</summary>
    public List <string> Getpayidyfk(int UserID, int CompID, int DisID, string price)
    {
        int           prepayid = 0;
        int           payid    = 0;
        int           regid    = 0;
        List <string> list     = new List <string>();

        Hi.Model.PAY_PrePayment Prepay     = new Hi.Model.PAY_PrePayment();
        Hi.BLL.PAY_PrePayment   bll_prepay = new Hi.BLL.PAY_PrePayment();
        Hi.BLL.PAY_Payment      bll_pay    = new Hi.BLL.PAY_Payment();
        Hi.BLL.PAY_RegisterLog  bll_reg    = new Hi.BLL.PAY_RegisterLog();
        Hi.Model.BD_Distributor dis        = new Hi.BLL.BD_Distributor().GetModel(DisID);
        try
        {
            //在表PAY_PrePayment中生成一条数据
            Prepay.CompID     = CompID;
            Prepay.DisID      = DisID;
            Prepay.OrderID    = 0;
            Prepay.Start      = 2;
            Prepay.PreType    = 1;
            Prepay.price      = Convert.ToDecimal(price);
            Prepay.Paytime    = DateTime.Now;
            Prepay.CreatDate  = DateTime.Now;
            Prepay.OldId      = 0;
            Prepay.CrateUser  = UserID;
            Prepay.AuditState = 2;
            Prepay.AuditUser  = 0;
            Prepay.IsEnabled  = 1;
            Prepay.ts         = DateTime.Now;
            Prepay.modifyuser = UserID;
            prepayid          = bll_prepay.Add(Prepay);
            if (prepayid > 0)
            {
                //如果pay_prepayment表中插入数据成功的话,在pay_payment表中插入一条数据
                int keyID = prepayid;
                Hi.Model.PAY_PrePayment Prepay_M = bll_prepay.GetModel(prepayid);
                string guid = Guid.NewGuid().ToString().Replace("-", "");
                Hi.Model.PAY_Payment pay = new Hi.Model.PAY_Payment();
                pay.OrderID      = keyID;
                pay.DisID        = DisID;
                pay.PayUser      = dis.DisName;
                pay.PayPrice     = Convert.ToDecimal(price);
                pay.guid         = Common.Number_repeat(guid);
                pay.IsAudit      = 2;
                pay.vdef3        = "2";
                pay.CreateDate   = DateTime.Now;
                pay.CreateUserID = UserID;
                pay.ts           = DateTime.Now;
                pay.modifyuser   = UserID;
                pay.Channel      = "6";
                payid            = bll_pay.Add(pay);
                //如果pay_prepayment表中插入数据成功的话,在PAY_RegisterLog表中插入一条数据
                Hi.Model.PAY_RegisterLog reg = new Hi.Model.PAY_RegisterLog();
                reg.OrderId    = keyID;
                reg.Ordercode  = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(keyID);
                reg.number     = pay.guid;
                reg.Price      = Convert.ToDecimal(price);
                reg.Payuse     = "企业钱包充值";
                reg.PayName    = dis.DisName;
                reg.DisID      = DisID;
                reg.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                reg.BankID     = "支付宝";
                reg.CreateUser = UserID;
                reg.CreateDate = DateTime.Now;
                reg.LogType    = 1375;
                regid          = bll_reg.Add(reg);
                if (payid > 0 && regid > 0)
                {
                    //返回的list第一行放支付流水号,第二行放企业订单号(支付时生成)
                    list.Add(ClsSystem.gnvl(pay.guid, ""));

                    list.Add(ClsSystem.gnvl(reg.Ordercode, ""));
                    return(list);
                }
            }
        }
        catch
        {
        }
        return(null);
    }
Example #24
0
    /// <summary>
    /// 绑定附件信息
    /// </summary>
    public void DataFileBind()
    {
        Hi.Model.PAY_PrePayment Pre = new Hi.BLL.PAY_PrePayment().GetModel(KeyID);
        if (Pre != null)
        {
            if (!string.IsNullOrEmpty(Pre.vdef5))
            {
                //    string[] files = Pre.vdef5.Split(new char[] { ',' });
                //    foreach (string file in files)
                //    {
                //        if (!string.IsNullOrEmpty(file))
                //        {
                //            LinkButton linkFile = new LinkButton();
                //            linkFile.Click += new EventHandler(Download_Click);
                //            if (file.LastIndexOf("_") != -1)
                //            {
                //                string text = file.Substring(0, file.LastIndexOf("_")) + Path.GetExtension(file);
                //                if (text.Length < 15)
                //                    linkFile.Text = text;
                //                else
                //                {
                //                    linkFile.Text = text.Substring(0, 15) + "...";
                //                }
                //                linkFile.Attributes.Add("title", text);
                //            }
                //            else
                //            {
                //                string text = file.Substring(0, file.LastIndexOf("-")) + Path.GetExtension(file);
                //                if (text.Length < 15)
                //                    linkFile.Text = text;
                //                else
                //                {
                //                    linkFile.Text = text.Substring(0, 15) + "...";
                //                }
                //                linkFile.Attributes.Add("title", text);
                //            }
                //            linkFile.Style.Add("margin-right", "5px");
                //            linkFile.Style.Add("text-decoration", "underline");
                //            linkFile.Attributes.Add("fileName", file);
                //            HtmlGenericControl div = new HtmlGenericControl("div");
                //            div.Controls.Add(linkFile);
                //            //HtmlImage img = new HtmlImage();
                //            //img.Src = "../../images/icon_del.png";
                //            //img.Attributes.Add("title", "删除附件");
                //            //img.Attributes.Add("onclick", "AnnexDel(this,'Dis'," + KeyID + ",'" + file + "')");
                //            //div.Controls.Add(img);
                //            DFile.Controls.Add(div);
                //        }
                //    }


                //附件
                if (Pre.vdef5 != "")
                {
                    StringBuilder li   = new StringBuilder();
                    string[]      atta = Pre.vdef5.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (atta.Length > 0)
                    {
                        foreach (var item in atta)
                        {
                            string[] att = item.Split(new string[] { "^^" }, StringSplitOptions.RemoveEmptyEntries);
                            if (att.Length > 1)
                            {
                                // li.AppendFormat("<li> <a href=\"{2}\" target=\"_blank\" class=\"name\">{0}(大小:{4}KB)</a><a href=\"javascript:;\"  class=\"bule del\" tip=\"{3}\" orderid=\"{1}\">删除</a><a href=\"{2}\" target=\"_blank\" class=\"bule\">下载</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                                li.AppendFormat("<li> <a href=\"{2}\" target=\"_blank\"  style=\"text-decoration:underline;margin-left:10px;\" class=\"name\">{0}(大小:{4}KB)</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                            }
                        }
                    }
                    ulAtta.InnerHtml = li.ToString();
                    //this.hrOrderFj.Value = dt.Rows[0]["Atta"].ToString();
                }
            }
        }
    }
Example #25
0
    /// <summary>
    /// 绑定信息
    /// </summary>
    public void bind()
    {
        List <Hi.Model.PAY_PaymentBank> paymentbanklist = new Hi.BLL.PAY_PaymentBank().GetList("", "  CompID=" + this.CompID, "");

        if (paymentbanklist.Count > 0)
        {
            Hi.Model.PAY_PaymentBank paymentbankmodel = paymentbanklist[0];
            bankid = paymentbankmodel.ID.ToString();

            this.txtDisUser.Value = paymentbankmodel.AccountName;//账户名称
            this.txtDisUser.Attributes.Add("class", "box noBox");
            this.txtDisUser.Attributes.Add("disabled", "true");

            this.txtbankcode.Value = paymentbankmodel.bankcode;//账户号码
            this.txtbankcode.Attributes.Add("class", "box noBox");
            this.txtbankcode.Attributes.Add("disabled", "true");

            this.txtbankAddress.Value = paymentbankmodel.bankAddress;//开户行地址
            this.txtbankAddress.Attributes.Add("class", "box noBox");
            this.txtbankAddress.Attributes.Add("disabled", "true");


            this.hidProvince.Value = paymentbankmodel.bankPrivate;//省
            this.ddlProvince.Attributes.Add("class", "prov select1 l xz2 noBox");
            this.ddlProvince.Attributes.Add("disabled", "true");

            this.hidCity.Value = paymentbankmodel.bankCity;//市
            this.ddlCity.Attributes.Add("class", "city select xz2 noBox");
            this.ddlCity.Attributes.Add("disabled", "true");

            this.hidArea.Value = paymentbankmodel.vdef1;//区
            this.ddlArea.Attributes.Add("class", "dist select  xz2 noBox");
            this.ddlArea.Attributes.Add("disabled", "true");

            this.chkIsno.Checked = paymentbankmodel.Isno == 1 ? true : false;//是否启用
            this.chkIsno.Attributes.Add("class", "fx noBox");
            this.chkIsno.Attributes.Add("disabled", "true");

            //如果在下拉列表中不存在的银行id,重新到银行表中查询加载
            ListItem list = ddlbank.Items.FindByValue(paymentbankmodel.BankID.ToString());
            if (list == null)
            {
                DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("BankCode ,BankName", "PAY_BankInfo", "BankCode=" + paymentbankmodel.BankID);
                if (dt.Rows.Count > 0)
                {
                    this.ddlbank.Items.Insert(0, new ListItem(Convert.ToString(dt.Rows[0]["BankName"]), Convert.ToString(dt.Rows[0]["BankCode"])));
                    this.ddlbank.SelectedIndex = 0;
                }
            }
            else
            {
                this.ddlbank.Value = paymentbankmodel.BankID.ToString();//银行Id

                DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("BankCode ,BankName", "PAY_BankInfo", "BankCode=" + paymentbankmodel.BankID);
                if (dt.Rows.Count > 0)
                {
                    this.ddlbank.Name = Convert.ToString(dt.Rows[0]["BankName"]);
                }
            }

            this.ddlbank.Attributes.Add("class", "xz noBox");
            this.ddlbank.Attributes.Add("disabled", "true");



            this.ddltype.Value = paymentbankmodel.type.ToString();//账户类型
            this.ddltype.Attributes.Add("class", "xz noBox");
            this.ddltype.Attributes.Add("disabled", "true");
            if (paymentbankmodel.type == 12)
            {
                this.tbdis.Attributes.Add("style", "display:none;");
            }

            this.SltPesontype.Value = paymentbankmodel.vdef2;//证件类型
            this.SltPesontype.Attributes.Add("class", "xz noBox");
            this.SltPesontype.Attributes.Add("disabled", "true");

            this.txtpesoncode.Value = paymentbankmodel.vdef3;//证件号码
            this.txtpesoncode.Attributes.Add("class", "box noBox");
            this.txtpesoncode.Attributes.Add("disabled", "true");


            //微信、支付宝不可编辑,需点击修改按钮
            Wx_ali_Disable();


            this.btnSave.Attributes.Add("style", "display:none;");
        }
        else
        {
            this.txtDisUser.Value     = "";    //账户名称
            this.txtbankcode.Value    = "";    //账户号码
            this.txtbankAddress.Value = "";    //开户行地址
            this.hidProvince.Value    = "";    //省
            this.hidCity.Value        = "";    //市
            this.hidArea.Value        = "";    //区
            this.chkIsno.Checked      = false; //是否启用
            this.ddlbank.Value        = "";    //银行Id
            this.ddltype.Value        = "";    //账户类型
            this.SltPesontype.Value   = "";    //证件类型
            this.txtpesoncode.Value   = "";    //证件号码

            this.btnUpdate.Attributes.Add("style", "display:none;");
            this.btnSave.Attributes.Add("style", "display:block;");
        }


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

        if (Sysl.Count > 0)
        {
            wx_aliId = Sysl[0].ID.ToString();
            //微信
            if (Sysl[0].wx_Isno == "1")
            {
                this.wx_chisno.Checked = true;
            }
            this.wx_chisno.Attributes.Add("class", "fx noBox");
            this.wx_chisno.Attributes.Add("disabled", "true");

            this.appid.Value = Convert.ToString(Sysl[0].wx_appid);
            this.appid.Attributes.Add("class", "box noBox");
            this.appid.Attributes.Add("disabled", "true");

            this.appsecret.Value = Convert.ToString(Sysl[0].wx_appsechet);
            this.appsecret.Attributes.Add("class", "box noBox");
            this.appsecret.Attributes.Add("disabled", "true");

            this.mchid.Value = Convert.ToString(Sysl[0].wx_mchid);
            this.mchid.Attributes.Add("class", "box noBox");
            this.mchid.Attributes.Add("disabled", "true");

            this.key.Value = Convert.ToString(Sysl[0].wx_key);
            this.key.Attributes.Add("class", "box noBox");
            this.key.Attributes.Add("disabled", "true");


            //支付宝
            if (Sysl[0].ali_isno == "1")
            {
                this.ali_chisno.Checked = true;
            }
            this.ali_chisno.Attributes.Add("class", "fx noBox");
            this.ali_chisno.Attributes.Add("disabled", "true");

            this.seller_email.Value = Convert.ToString(Sysl[0].ali_seller_email);
            this.seller_email.Attributes.Add("class", "box noBox");
            this.seller_email.Attributes.Add("disabled", "true");

            this.partner.Value = Convert.ToString(Sysl[0].ali_partner);
            this.partner.Attributes.Add("class", "box noBox");
            this.partner.Attributes.Add("disabled", "true");

            this.PayKey.Value = Convert.ToString(Sysl[0].ali_key);
            this.PayKey.Attributes.Add("class", "box noBox");
            this.PayKey.Attributes.Add("disabled", "true");
            this.alirsa.Value = Convert.ToString(Sysl[0].ali_RSAkey);
            this.alirsa.Attributes.Add("class", "box noBox");
            this.alirsa.Attributes.Add("disabled", "true");
            //收款帐号不可编辑,需点击修改按钮
            Paymentbank_disable();

            this.btnUpdate.Attributes.Add("style", "display:block;");
        }
        else //默认值显示
        {
            //微信
            this.appid.Value     = "";
            this.appsecret.Value = "";
            this.mchid.Value     = "";
            this.key.Value       = "";
            //支付宝
            this.seller_email.Value = "";
            this.partner.Value      = "";
            this.PayKey.Value       = "";
        }
    }
Example #26
0
    /// <summary>
    /// 订单支付
    /// </summary>
    /// <param name="orderid">订单ID</param>
    /// <param name="txtPayOrder">支付金额</param>
    /// <param name="price">企业钱包金额</param>
    /// <param name="yfk">预付款</param>
    /// <param name="payPas"></param>
    public Wxpay_Url PayOrder(int orderid, decimal txtPayOrder, decimal price, int yfk, string payPas)
    {
        //使用企业钱包

        OrderModel = new Hi.BLL.DIS_Order().GetModel(orderid);
        disModel   = new Hi.BLL.BD_Distributor().GetModel(OrderModel.DisID);



        #region  界面上显示
        this.lblOrderNO.InnerText = OrderModel.ReceiptNo.Trim().ToString();
        this.fee.InnerText        = this.CompName;//收款方
        // this.lblOrderNO.HRef = "../neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey);
        #endregion 界面上显示


        #region 企业钱包支付 begin

        if (disModel == null)
        {
            ErrMessage("数据异常,代理商有误", orderid.ToString());
        }

        decimal sumPrice = new Hi.BLL.PAY_PrePayment().sums(disModel.ID, disModel.CompID); //剩余企业钱包
        int     disid    = OrderModel.DisID;                                               //代理商ID
        string  password = disModel.Paypwd;

        if (yfk == 1)
        {
            if (payPas == null || payPas.Trim().ToString() == "")
            {
                ErrMessage("企业钱包密码不能为空", orderid.ToString());
            }
            payPas = payPas.Trim().ToString();
            if (password == Util.md5("123456"))
            {
                ErrMessage("请先修改企业钱包支付密码", orderid.ToString());
            }
            else
            {
                if (payPas == "")
                {
                    ErrMessage("密码不能为空", orderid.ToString());
                }
            }
        }

        decimal payPrice = 0;//支付金额
        if (txtPayOrder == 0)
        {
            ErrMessage("支付金额不能为0", orderid.ToString());
        }
        if (yfk == 1 && txtPayOrder < price)
        {
            ErrMessage("使用企业钱包大于支付金额!", orderid.ToString());
        }
        if (yfk == 1)
        {
            payPrice = txtPayOrder - price;
        }
        else
        {
            payPrice = txtPayOrder;
        }


        if (txtPayOrder > OrderModel.AuditAmount + OrderModel.OtherAmount - OrderModel.PayedAmount)
        {
            ErrMessage("支付金额大于未支付金额,不能支付!", orderid.ToString());
        }
        if (!((
                  (OrderModel.Otype == (int)Enums.OType.赊销订单 && (OrderModel.OState != (int)Enums.OrderState.退回 && OrderModel.OState != (int)Enums.OrderState.未提交 && OrderModel.OState != (int)Enums.OrderState.待审核) && (OrderModel.PayState == (int)Enums.PayState.未支付 || OrderModel.PayState == (int)Enums.PayState.部分支付)) ||
                  (OrderModel.Otype != (int)Enums.OType.赊销订单 && OrderModel.Otype != (int)Enums.OType.推送账单 && (OrderModel.OState == (int)Enums.OrderState.已审 || OrderModel.OState == (int)Enums.OrderState.已发货 || OrderModel.OState == (int)Enums.OrderState.已到货) && (OrderModel.PayState == (int)Enums.PayState.未支付 || OrderModel.PayState == (int)Enums.PayState.部分支付)) ||
                  (OrderModel.Otype == (int)Enums.OType.推送账单 && OrderModel.OState == (int)Enums.OrderState.已审 && (OrderModel.PayState == (int)Enums.PayState.部分支付 || OrderModel.PayState == (int)Enums.PayState.未支付))
                  ) &&
              OrderModel.OState != (int)Enums.OrderState.已作废))
        {
            if (OrderModel.Otype == (int)Enums.OType.推送账单)
            {
                ErrMessage("账单异常,不能支付", orderid.ToString());
            }
            else
            {
                ErrMessage("订单异常,不能支付", orderid.ToString());
            }
        }

        if (yfk == 1 && price > 0)
        {
            //企业钱包处理
            if (sumPrice < price)
            {
                ErrMessage("企业钱包余额不足", orderid.ToString());
            }
            if (disModel.Paypwd != Util.md5(payPas))
            {
                ErrMessage("支付密码不正确", orderid.ToString());
            }
            Hi.Model.PAY_PrePayment prepayModel = new Hi.Model.PAY_PrePayment();
            prepayModel.CompID     = disModel.CompID;
            prepayModel.DisID      = disModel.ID;
            prepayModel.OrderID    = OrderModel.ID;
            prepayModel.Start      = 2;
            prepayModel.PreType    = 5;
            prepayModel.price      = price * -1;
            prepayModel.Paytime    = DateTime.Now;
            prepayModel.CreatDate  = DateTime.Now;
            prepayModel.CrateUser  = this.UserID;
            prepayModel.AuditState = 2;
            prepayModel.IsEnabled  = 1;
            prepayModel.ts         = DateTime.Now;
            prepayModel.modifyuser = this.UserID;
            prepayModel.guid       = Common.Number_repeat(Guid.NewGuid().ToString().Replace("-", ""));
            // prepayModel.vdef1 = "订单支付";
            prepayid = new Hi.BLL.PAY_PrePayment().Add(prepayModel);
            int prepay = 0;
            int order  = 0;
            if (prepayid > 0 && payPrice == 0)//payPrice(网银支付金额)= 0 ,只用企业钱包支付,修改状态
            {
                SqlConnection con = new SqlConnection(LocalSqlServer);
                con.Open();
                SqlTransaction sqlTrans = con.BeginTransaction();
                try
                {
                    prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayid, sqlTrans);        //修改企业钱包状态
                    order  = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, OrderModel.ID, price, sqlTrans); //修改订单状态
                    if (prepay > 0 && order > 0)
                    {
                        sqlTrans.Commit();
                    }
                    else
                    {
                        sqlTrans.Rollback();
                    }
                }
                catch
                {
                    prepay = 0;
                    order  = 0;
                    sqlTrans.Rollback();
                }
                finally
                {
                    con.Close();
                }
                if (prepay > 0 && order > 0)
                {
                    try
                    {
                        if (OrderModel.Otype == (int)Enums.OType.推送账单)
                        {
                            Utils.AddSysBusinessLog(disModel.CompID, "Order", OrderModel.ID.ToString(), "账单支付", "支付:" + price.ToString("0.00") + "元(企业钱包支付)", this.UserID.ToString());
                        }
                        else
                        {
                            Utils.AddSysBusinessLog(disModel.CompID, "Order", OrderModel.ID.ToString(), "订单支付", "支付:" + price + "元(企业钱包支付)", this.UserID.ToString());
                        }
                        if (OrderModel.Otype != 9)
                        {
                            OrderInfoType.AddIntegral(this.CompID, this.DisID, "1", 1, OrderModel.ID, price, "订单支付", "", this.UserID);
                        }
                        new Common().GetWxService("2", OrderModel.ID.ToString(), "1", price);
                    }
                    catch (Exception ex)
                    {
                        ErrMessage("支付失败", orderid.ToString());
                    }

                    if (OrderModel.Otype == (int)Enums.OType.推送账单)
                    {
                        Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(OrderModel.ID.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false);
                    }
                    else
                    {
                        Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("1", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(OrderModel.ID.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false);
                    }
                }
            }
        }

        #endregion



        #region  插入支付表记录

        Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment();
        string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分

        string guid = Guid.NewGuid().ToString().Replace("-", "");
        payModel.OrderID      = OrderModel.ID; // orderid;
        payModel.DisID        = this.DisID;
        payModel.Type         = 0;             // isDBPay;
        payModel.PayUser      = disModel.DisName;
        payModel.PayPrice     = payPrice;
        payModel.IsAudit      = 2;
        payModel.guid         = Common.Number_repeat(guid);
        payModel.vdef3        = "1"; //1,订单支付,2,预付款充值、汇款
        payModel.vdef4        = orderNo;
        payModel.CreateDate   = DateTime.Now;
        payModel.CreateUserID = this.UserID;
        payModel.ts           = DateTime.Now;
        payModel.modifyuser   = this.UserID;
        payModel.PrintNum     = 1; //支付宝支付无需结算
        //判断账户类型,判断支付渠道
        payModel.Channel = "7";    //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付
        payModel.State   = 0;      //手续费收取方
        payModel.vdef5   = "0.00"; //支付手续费
        payid            = new Hi.BLL.PAY_Payment().Add(payModel);

        if (prepayid > 0)
        {
            Hi.Model.PAY_PrePayment prepayMent = new Hi.BLL.PAY_PrePayment().GetModel(prepayid);
            prepayMent.vdef4 = payid.ToString();//与企业钱包关联
            new Hi.BLL.PAY_PrePayment().Update(prepayMent);
        }

        Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog();
        regModel.OrderId    = OrderModel.ID;// orderid;
        regModel.Ordercode  = orderNo + payid.ToString();
        regModel.number     = payModel.guid;
        regModel.Price      = payPrice;
        regModel.Payuse     = "订单支付";
        regModel.PayName    = disModel.DisName;
        regModel.DisID      = OrderModel.DisID;
        regModel.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        regModel.Remark     = OrderModel.Remark;// orderModel.Remark;
        regModel.DisName    = new Hi.BLL.BD_Company().GetModel(disModel.CompID).CompName;
        regModel.BankID     = "支付宝支付";
        regModel.CreateUser = this.UserID;
        regModel.CreateDate = DateTime.Now;
        regModel.LogType    = 1311;
        int regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);
        if (payid <= 0 || regid <= 0)
        {
            Response.Redirect("Error.aspx?type=" + Common.DesEncrypt("3", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(Convert.ToString(KeyID), Common.EncryptKey) + "&msg=" + Common.DesEncrypt("支付失败!", Common.EncryptKey), false);
        }

        //订单所有商品明细


        DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + orderid);
        foreach (DataRow dr in l.Rows)
        {
            GoodsName += dr["GoodsName"] + ",";
        }
        GoodsName = GoodsName.Substring(0, GoodsName.Length - 1);//去掉最后一个逗号
        if (GoodsName.Length > 15)
        {
            GoodsName = GoodsName.Substring(0, 10) + "...";
        }



        #endregion


        int amount = Convert.ToInt32(payPrice * 100);//支付金额(单位:分)

        //隐藏域赋值
        this.hidguid.Value  = payModel.guid;
        this.hidprice.Value = payPrice.ToString();
        this.hidordid.Value = payModel.OrderID.ToString();
        this.hidpid.Value   = payid.ToString();
        this.hidppid.Value  = prepayid.ToString();

        // btnWxPay_Click(payModel.guid, orderid.ToString(), amount);

        Wxpay_Url wxpaymodel = new Wxpay_Url();
        wxpaymodel.Guid    = payModel.guid;
        wxpaymodel.OrderID = orderid.ToString();
        wxpaymodel.Amount  = amount;


        wxpaymodel.Hidguid  = payModel.guid;
        wxpaymodel.Hidprice = payModel.PayPrice.ToString();
        wxpaymodel.Hidordid = payModel.OrderID.ToString();
        wxpaymodel.Hidpid   = payid.ToString();
        wxpaymodel.Hidppid  = prepayid.ToString();

        return(wxpaymodel);
    }
Example #27
0
    /// <summary>
    /// 订单信息
    /// </summary>
    public void databind()
    {
        if (KeyID != 0)
        {
            hidOrderID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);
            string where     = "and isnull(o.dr,0)=0 and o.otype<>9  and o.ID= " + KeyID;
            DataTable dt = new Hi.BLL.DIS_Order().GetList("", where);

            if (dt != null && dt.Rows.Count > 0)
            {
                CompID         = dt.Rows[0]["CompID"].ToString().ToInt(0);
                DisID          = dt.Rows[0]["DisID"].ToString().ToInt(0);
                hidDisID.Value = DisID.ToString();

                //判断改该条数据代理商是否有操作权限
                if (!Common.PageDisOperable("Order", KeyID, DisID))
                {
                    Response.Redirect("../NoOperable.aspx");
                    return;
                }

                //////再次购买
                ////buyagain.Visible = false;
                //////订单修改
                ////modifyorder.Visible = false;
                //订单作废
                //ordervoid.Visible = false;
                //////订单审核
                ////orderaudit.Visible = false;

                Digits          = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", dt.Rows[0]["CompID"].ToString().ToInt(0));
                hidDigits.Value = Digits;

                isbate = OrderInfoType.rdoOrderAudit("订单支付返利是否启用", CompID).ToInt(0);
                if (isbate == 0)
                {
                    trbate.Visible = false;
                    rebate.Visible = false;
                }

                OState = dt.Rows[0]["OState"].ToString().ToInt(0);
                if (OState == (int)Enums.OrderState.已作废)
                {
                    orderDelete.Visible = true;
                }
                else
                {
                    orderDelete.Visible = false;
                }
                IsOutState          = dt.Rows[0]["IsOutState"].ToString().ToInt(0);
                payState            = dt.Rows[0]["PayState"].ToString().ToInt(0);
                hidIsOutstate.Value = dt.Rows[0]["IsOutState"].ToString();
                hidOstate.Value     = OState.ToString();
                hidpaystate.Value   = payState.ToString();

                #region 订单操作按钮

                //switch (OState)
                //{
                //    case (int)Enums.OrderState.未提交:
                //        //modifyorder.Visible = true;
                //        //buyagain.Visible = true;
                //        //orderaudit.Visible = true;
                //        //ordervoid.Visible = true;
                //        deliver.Attributes.Add("style", "display: none;");
                //        break;
                //    case (int)Enums.OrderState.待审核:
                //        //modifyorder.Visible = true;
                //        //buyagain.Visible = true;
                //        //orderaudit.Visible = true;
                //        //ordervoid.Visible = true;
                //        deliver.Attributes.Add("style", "display: none;");
                //        break;
                //    case (int)Enums.OrderState.已审:
                //        //订单审核前,可以修改订单。
                //        buyagain.Visible = true;
                //        if (payState == 0)
                //        {
                //            //订单支付前订单可以作废,支付后不能作废订单
                //            ordervoid.Visible = true;
                //        }
                //        break;
                //    case (int)Enums.OrderState.退货处理:
                //        buyagain.Visible = true;
                //        fulfil = signde;
                //        break;
                //    case (int)Enums.OrderState.已发货:
                //        modifyorder.Visible = false;
                //        buyagain.Visible = true;
                //        break;
                //    case (int)Enums.OrderState.已到货:
                //        modifyorder.Visible = false;
                //        buyagain.Visible = true;
                //        fulfil = signde;
                //        break;
                //    case (int)Enums.OrderState.已作废:
                //        modifyorder.Visible = false;
                //        buyagain.Visible = true;
                //        break;
                //    case (int)Enums.OrderState.已退货:
                //        buyagain.Visible = true;
                //        fulfil = signde;
                //        break;
                //    default:
                //        break;
                //}

                #endregion

                // 订单编号
                lblReceiptNo.InnerText  = dt.Rows[0]["ReceiptNo"].ToString();
                lblDisName.InnerText    = Common.GetDisValue(dt.Rows[0]["DisID"].ToString().ToInt(0), "DisName").ToString();
                lblCreateDate.InnerText = dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblOstate.InnerText     = OrderType.GetOState(dt.Rows[0]["OState"].ToString(), dt.Rows[0]["IsOutState"].ToString());

                //订单流程
                lblTotalAmount.InnerText = dt.Rows[0]["TotalAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["TotalAmount"].ToString().ToDecimal().ToString("N");
                lblProAmount.InnerText   = dt.Rows[0]["ProAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["ProAmount"].ToString().ToDecimal().ToString("N");

                lblbateAmount.InnerText = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("N");
                lblbate.InnerText       = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("0.00");

                lblPostFee.InnerText     = dt.Rows[0]["PostFee"].ToString() == "" ? "0.00" : dt.Rows[0]["PostFee"].ToString().ToDecimal().ToString("0.00");
                lblAuditAmount.InnerText = dt.Rows[0]["AuditAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["AuditAmount"].ToString().ToDecimal().ToString("N");

                //下单信息
                lblArriveDate.InnerText = dt.Rows[0]["ArriveDate"].ToString() == "" ? "" : dt.Rows[0]["ArriveDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblGiveMode.InnerText   = dt.Rows[0]["GiveMode"].ToString();
                iRemark.InnerText       = dt.Rows[0]["Remark"].ToString();

                //收货地址
                lblPrincipal.InnerText = dt.Rows[0]["Principal"].ToString();
                lblPhone.InnerText     = dt.Rows[0]["Phone"].ToString();
                lblAddress.InnerText   = dt.Rows[0]["Address"].ToString();
                hidAddrID.Value        = dt.Rows[0]["AddrID"].ToString();

                //开票信息
                if (dt.Rows[0]["IsOBill"].ToString() == "1")
                {
                    hidDisAccID.Value = dt.Rows[0]["DisAccID"].ToString();
                    hidval.Value      = dt.Rows[0]["IsOBill"].ToString();
                    string Billing = string.Empty;
                    Billing += "发票抬头:<label id=\"lblRise\" runat=\"server\">" + dt.Rows[0]["Rise"].ToString() + "</label>";
                    Billing += ",发票内容:<label id=\"lblContent\" runat=\"server\">" + dt.Rows[0]["Content"].ToString() + "</label>";
                    if (!string.IsNullOrEmpty(dt.Rows[0]["OBank"].ToString()))
                    {
                        Billing += ",开户银行:<label id=\"lblOBank\" runat=\"server\">" + dt.Rows[0]["OBank"].ToString() + "</label>";
                        Billing += ",开户账户:<label id=\"lblOAccount\" runat=\"server\">" + dt.Rows[0]["OAccount"].ToString() + "</label>";
                        Billing += ",纳税人登记号:<label id=\"lblTRNumber\" runat=\"server\">" + dt.Rows[0]["TRNumber"].ToString() + "</label>";
                    }
                    iInvoice.InnerHtml = Billing;

                    //lblRise.InnerText = dt.Rows[0]["Rise"].ToString();
                    //lblContent.InnerText = dt.Rows[0]["Content"].ToString();
                    //lblOBank.InnerText = dt.Rows[0]["OBank"].ToString();
                    //lblOAccount.InnerText = dt.Rows[0]["OAccount"].ToString();
                    //lblTRNumber.InnerText = dt.Rows[0]["TRNumber"].ToString();
                }
                else
                {
                    this.iInvoice.InnerHtml = "不开发票";
                }

                //发票信息
                lblBillNo.InnerText = dt.Rows[0]["BillNo"].ToString();
                lblIsBill.InnerText = dt.Rows[0]["IsBill"].ToString() == "1" ? "是" : "否";
                lblIsBill.Attributes.Add("tip", dt.Rows[0]["IsBill"].ToString());
                this.hidisBill.Value = dt.Rows[0]["IsBill"].ToString();


                #region  订单支付信息

                TotalAmount = Convert.ToDecimal(dt.Rows[0]["AuditAmount"]).ToString("0.00");
                PayedAmount = Convert.ToDecimal(dt.Rows[0]["PayedAmount"]).ToString("0.00");

                //订单已支付不显示支付按钮(未审核、未支付完成)
                if (Convert.ToInt32(dt.Rows[0]["OState"]) == 1 || (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"]) == 0))
                {
                    btn_pay.Visible = false;
                }
                paymoney = (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"])).ToString("0.00");

                //加密keyId
                desKeyID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);


                //绑定支付流水信息
                DataTable paytable = new Hi.BLL.PAY_PrePayment().GetPayedItem(KeyID);
                rptmessage.DataSource = paytable;
                rptmessage.DataBind();


                //初始值加载
                txtArriveDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
                DataTable dtpayment = new Hi.BLL.PAY_PrePayment().GetDate(" top 1   CreateDate, payName ,paycode ,paybank", "pay_payment", " DisID=" + DisID + " and vdef3=5 order by  CreateDate desc");
                foreach (DataRow dr in dtpayment.Rows)
                {
                    bankname.Value = Convert.ToString(dr["payName"]);
                    bankcode.Value = Convert.ToString(dr["paycode"]);
                    bank.Value     = Convert.ToString(dr["paybank"]);
                }


                #endregion
                //附件
                if (dt.Rows[0]["Atta"].ToString() != "")
                {
                    StringBuilder li   = new StringBuilder();
                    string[]      atta = dt.Rows[0]["Atta"].ToString().Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (atta.Length > 0)
                    {
                        foreach (var item in atta)
                        {
                            string[] att = item.Split(new string[] { "^^" }, StringSplitOptions.RemoveEmptyEntries);
                            if (att.Length > 1)
                            {
                                li.AppendFormat("<li> <a href=\"{2}\" target=\"_blank\" class=\"name\">{0}(大小:{4}KB)</a><a href=\"javascript:;\"  class=\"bule del\" tip=\"{3}\" orderid=\"{1}\">删除</a><a href=\"{2}\" target=\"_blank\" class=\"bule\">下载</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                            }
                        }
                    }
                    ulAtta.InnerHtml     = li.ToString();
                    this.hrOrderFj.Value = dt.Rows[0]["Atta"].ToString();
                }

                #region 订单明细

                //订单所有商品明细
                DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + KeyID);
                if (l != null && l.Rows.Count > 0)
                {
                    rptOrderD.DataSource = l;
                    rptOrderD.DataBind();

                    //待发货商品
                    DataTable lno = SelectGoodsInfo.SreeenDataTable(l, "isnull(IsOut,0)=0"); //l.Select(string.Format("IsOut={0}", 0));
                    if (lno != null && lno.Rows.Count > 0)
                    {
                        txtDate.Value       = DateTime.Now.ToString("yyyy-MM-dd");
                        rptIsout.DataSource = lno;
                        rptIsout.DataBind();
                    }
                    else
                    {
                        deliver.Attributes.Add("style", "display: none;");
                    }

                    //已发货商品
                    List <Hi.Model.DIS_OrderOutDetail> loud = new Hi.BLL.DIS_OrderOutDetail().GetList("", " isnull(dr,0)=0 and OrderID=" + KeyID, "");
                    //发货单 作废-- and o.IsAudit<>3
                    DataTable lo = new Hi.BLL.DIS_OrderOut().GetList("", " isnull(o.dr,0)=0 and o.OrderID=" + KeyID + " Order by o.IsAudit");

                    if (loud != null && loud.Count > 0)
                    {
                        //outbind(lo, l, loud);

                        outGoods.InnerHtml = SelectGoodsInfo.outbind(lo, l, loud, Digits, 1);
                    }

                    #region 流程时间控件

                    //订单流程时间显示
                    //订单提交时间
                    CreateDate = dt.Rows[0]["CreateDate"].ToString() != "" ? dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";

                    //订单审核时间
                    AuditDate = dt.Rows[0]["AuditDate"].ToString() != "" ? dt.Rows[0]["AuditDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";

                    if (lo != null && lo.Rows.Count > 0)
                    {
                        if (((int)Enums.OrderState.已发货 <= OState || OState == (int)Enums.OrderState.退货处理) && (IsOutState == 3 || IsOutState == 4))
                        {
                            //订单发货时间
                            DataRow[] sendlo = lo.Select("IsAudit<>3");
                            DataRow[] dv     = sendlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dv.Length > 0)
                            {
                                sendde = dv[0]["SendDate"].ToString() != "" ? dv[0]["SendDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }
                        if ((int)Enums.OrderState.已到货 <= OState || OState == (int)Enums.OrderState.退货处理)
                        {
                            //订单签收时间
                            DataRow[] signlo = lo.Select("IsAudit<>3 and IsSign=1");
                            DataRow[] dr     = signlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dr.Length > 0)
                            {
                                signde = dr[0]["SignDate"].ToString() != "" ? dr[0]["SignDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }
                    }
                    #endregion
                }
                #endregion
            }
            else
            {
                Response.Redirect("../NoOperable.aspx");
                return;
            }
        }
    }
Example #28
0
    /// <summary>
    /// 企业钱包充值
    /// </summary>
    /// <param name="rechengID">充值记录Id</param>
    public Wxpay_Url PayRechang(int rechengID)
    {
        //企业钱包充值记录
        Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(rechengID);
        decimal price = prepayM.price;

        #region  界面上显示
        txtPayOrder = price;
        this.lblOrderNO.InnerText = prepayM.guid.ToString();
        this.fee.InnerText        = this.CompName;//收款方
        // this.lblOrderNO.HRef = "../neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey);
        #endregion 界面上显示


        #region 支付记录
        int    payid = 0;
        int    regid = 0;
        string guid  = Guid.NewGuid().ToString().Replace("-", "");
        Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment();
        payModel.OrderID      = rechengID;
        payModel.DisID        = this.DisID;
        payModel.PayUser      = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName;
        payModel.PayPrice     = price;
        payModel.guid         = Common.Number_repeat(guid);
        payModel.IsAudit      = 2;
        payModel.vdef3        = "2";
        payModel.CreateDate   = DateTime.Now;
        payModel.CreateUserID = this.UserID;
        payModel.ts           = DateTime.Now;
        payModel.modifyuser   = this.UserID;
        payModel.PrintNum     = 1;
        payModel.Channel      = "7";    //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付
        payModel.State        = 0;      //手续费收取方
        payModel.vdef5        = "0.00"; //支付手续费

        payid = new Hi.BLL.PAY_Payment().Add(payModel);

        Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog();
        regModel.OrderId    = rechengID;
        regModel.Ordercode  = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(rechengID);
        regModel.number     = payModel.guid;
        regModel.Price      = price;
        regModel.Payuse     = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : "";
        regModel.PayName    = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName;
        regModel.DisID      = this.DisID;
        regModel.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        regModel.Remark     = prepayM.vdef1;
        regModel.DisName    = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName;
        regModel.BankID     = "支付宝";
        regModel.CreateUser = this.UserID;
        regModel.CreateDate = DateTime.Now;
        regModel.LogType    = 1375;
        regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);

        if (payid <= 0 || regid <= 0)
        {
            //JScript.AlertMsg(this, "数据异常!");
            ErrMessage("数据异常", rechengID.ToString());
        }
        GoodsName = "钱包充值";

        #endregion

        int amount = Convert.ToInt32(price * 100);//支付金额(单位:分)

        //隐藏域赋值
        this.hidguid.Value  = payModel.guid;
        this.hidprice.Value = price.ToString();
        this.hidordid.Value = payModel.OrderID.ToString();
        this.hidpid.Value   = payid.ToString();
        this.hidppid.Value  = "recharge";// prepayid.ToString();


        Wxpay_Url wxpaymodel = new Wxpay_Url();
        wxpaymodel.Guid    = payModel.guid;
        wxpaymodel.OrderID = orderid.ToString();
        wxpaymodel.Amount  = amount;

        wxpaymodel.Hidguid  = payModel.guid;
        wxpaymodel.Hidprice = price.ToString();
        wxpaymodel.Hidordid = payModel.OrderID.ToString();
        wxpaymodel.Hidpid   = payid.ToString();
        wxpaymodel.Hidppid  = "recharge";
        return(wxpaymodel);

        //btnWxPay_Click(payModel.guid, orderid.ToString(), amount);
    }
Example #29
0
    public void databind()
    {
        if (!string.IsNullOrEmpty(Request["DisID"]))
        {
            DisID = (Request["DisID"] + "").ToInt(0);
        }

        hidDisID.Value = DisID.ToString();

        if ((Request["val"] + "") != "0")
        {
            int val = Request["val"].ToString().ToInt(0);

            if (val == 0)
            {
                this.checkbox_2_1.Checked = true;
            }
            else if (val == 1)
            {
                this.checkbox_2_2.Checked = true;
            }
            else if (val == 2)
            {
                this.checkbox_2_3.Checked = true;
            }

            this.txtLookUp.Value  = Common.NoHTML(Request["Rise"].ToString());
            this.txtContext.Value = Common.NoHTML(Request["Context"].ToString());
            this.txtBank.Value    = Common.NoHTML(Request["Bank"].ToString());
            this.txtAccount.Value = Common.NoHTML(Request["Account"].ToString());
            this.txtRegNo.Value   = Common.NoHTML(Request["RegNo"].ToString());
        }
        else
        {
            //List<Hi.Model.BD_DisAccount> l = new Hi.BLL.BD_DisAccount().GetList("", " DisID=" + DisID + "and isnull(dr,0)=0", "");
            List <Hi.Model.YZT_FCmaterials> fCmaterialsList = new Hi.BLL.YZT_FCmaterials().GetList("", " DisID =" + DisID + " and dr=0 ", "");

            this.checkbox_2_1.Checked = true;

            if (fCmaterialsList != null && fCmaterialsList.Count > 0)
            {
                //hidDisAccID.Value = Common.NoHTML(l[0].ID.ToString());
                txtLookUp.Value  = Common.NoHTML(fCmaterialsList[0].Rise.ToString());
                txtContext.Value = Common.NoHTML(fCmaterialsList[0].Content.ToString());

                DataTable dt = new Hi.BLL.PAY_PrePayment().GetDate("BankCode ,BankName", "PAY_BankInfo", "BankCode=" + fCmaterialsList[0].OBank);
                if (dt.Rows.Count > 0)
                {
                    txtBank.Value = Common.NoHTML(dt.Rows[0]["BankName"].ToString());
                }

                txtAccount.Value = Common.NoHTML(fCmaterialsList[0].OAccount.ToString());
                txtRegNo.Value   = Common.NoHTML(fCmaterialsList[0].TRNumber.ToString());
            }
            else
            {
                Hi.Model.BD_Distributor disModel = new Hi.BLL.BD_Distributor().GetModel(DisID);

                txtLookUp.Value  = disModel.DisName;
                txtContext.Value = "商品明细";
            }
        }
    }
Example #30
0
    /// <summary>
    ///  结算
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void btnAudit_Click(object source, EventArgs e)
    {
        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; //订单备注

        //-----银行信息
        string orgcode              = string.Empty; //机构代码
        int    accountType          = 0;            //帐号类型
        string paymentaccountname   = string.Empty; //账户名称
        string paymentaccountnumber = string.Empty; //账户号码
        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

        string str = CB_SelAll();

        if (string.IsNullOrEmpty(str))
        {
            JScript.AlertMsgOne(this, "请选择要结算的记录!", JScript.IconOption.错误);
            return;
        }


        string[] strArry = str.Split(',');

        foreach (string s in strArry)
        {
            ordID = Convert.ToInt32(s);//订单编号

            DataTable dt_order = new Hi.BLL.PAY_PrePayment().GetdataTable_pre(1, " and PAY_PrePayment.ID =" + ordID);
            if (dt_order.Rows.Count <= 0)
            {
                JScript.AlertMsgOne(this, "支付数据中没有相关的记录,无法进行收款结算!", JScript.IconOption.错误);
                return;
            }
            foreach (DataRow dr in dt_order.Rows)
            {
                compID    = Convert.ToInt32(dr["CompID"]);
                disID     = Convert.ToInt32(dr["DisID"]);
                price     = Convert.ToInt64(Convert.ToDecimal(dr["PayPrice"]) * 100);
                ReceiptNo = Convert.ToString(dr["ReceiptNo"]);
                guid      = Convert.ToString(dr["GUID"]);
                remark    = Convert.ToString(dr["Remark"]);

                //查找企业银行信息(绑定>默认)
                DataTable dt_bank_bydis = new Hi.BLL.PAY_PrePayment().GetdataTable_pre(2, " and PAY_PaymentAccountdtl.DisID=" + disID); //结算接口,银行信息--已代理商为核心
                DataTable dt_bank_comp  = new Hi.BLL.PAY_PrePayment().GetdataTable_pre(3, " and PAY_PaymentBank.CompID=" + compID);     //结算接口,银行信息--已企业为主,


                if (dt_bank_bydis.Rows.Count > 0)
                {
                    foreach (DataRow drdis in dt_bank_bydis.Rows)
                    {
                        orgcode              = Convert.ToString(drdis["OrgCode"]); //机构代码
                        accountType          = Convert.ToInt32(drdis["type"]);     //帐号类型
                        paymentaccountname   = Convert.ToString(drdis["payName"]); //账户名称
                        paymentaccountnumber = Convert.ToString(drdis["PayCode"]); //账户号码
                        //收款方在银行开立的账户
                        bankId        = "700";                                     // Convert.ToString(drdis["BankID"]); ;//银行ID
                        accountname   = Convert.ToString(drdis["AccountName"]);    //账户名称
                        accountnumber = Convert.ToString(drdis["bankcode"]);       //账户号码
                        branchname    = Convert.ToString(drdis["bankAddress"]);    //开会行地址
                        province      = Convert.ToString(drdis["bankprivate"]);    //开会所在省
                        city          = Convert.ToString(drdis["bankcity"]);       //开会所在市
                    }
                }
                else if (dt_bank_comp.Rows.Count > 0)
                {
                    foreach (DataRow drcomp in dt_bank_comp.Rows)
                    {
                        orgcode              = Convert.ToString(drcomp["OrgCode"]); //机构代码
                        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)
                {
                    JScript.AlertMsgOne(this, "无法进行收款结算,请在【结算账户管理】中维护收款帐号信息!", JScript.IconOption.错误);
                    return;
                }
                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  = this.UserID;
                    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);

                            if ("2000".Equals(tx134xResponse.getCode()))
                            {
                                //处理业务

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

                                //修改转账汇款状态
                                Hi.Model.PAY_PrePayment PrepaymentModel = new Hi.BLL.PAY_PrePayment().GetModel(ordID);
                                PrepaymentModel.vdef2 = "1";//修改结算标示为已结算
                                bool fal = new Hi.BLL.PAY_PrePayment().Update(PrepaymentModel);
                                if (fal)
                                {
                                    Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), "转账汇款结算", "");
                                    JScript.AlertMsgOne(this, "操作成功!", JScript.IconOption.笑脸);
                                    Bind();
                                }
                            }
                            else
                            {
                                Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), strs, "");
                                JScript.AlertMsgOne(this, strs + "!", JScript.IconOption.错误);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    else
                    {
                        Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), "系统繁忙,接口日志文件插入失败!", "");
                        JScript.AlertMsgOne(this, "系统繁忙,接口日志文件插入失败!", JScript.IconOption.错误);
                    }
                }

                //支付账户类型判断**************************************************************************************
                else if (accountType == 20 && paymentaccountname != "" && paymentaccountnumber != "")
                {
                    //先插入日志表,
                    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  = this.UserID;
                    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);

                            if ("2000".Equals(tx134xResponse.getCode()))
                            {
                                //处理业务

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

                                //修改转账汇款状态
                                Hi.Model.PAY_PrePayment PrepaymentModel = new Hi.BLL.PAY_PrePayment().GetModel(ordID);
                                PrepaymentModel.vdef2 = "1";//修改结算标示为已结算
                                bool fal = new Hi.BLL.PAY_PrePayment().Update(PrepaymentModel);
                                if (fal)
                                {
                                    Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), "转账汇款结算", "");
                                    JScript.AlertMsgOne(this, "操作成功!", JScript.IconOption.笑脸);
                                    Bind();
                                }
                            }
                            else
                            {
                                Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), strs, "");
                                JScript.AlertMsgOne(this, strs + "!", JScript.IconOption.错误);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    else
                    {
                        Utils.AddSysBusinessLog(CompID, "PrePayment", ordID.ToString(), "系统繁忙,接口日志文件插入失败!", "");
                        JScript.AlertMsgOne(this, "系统繁忙,接口日志文件插入失败!", JScript.IconOption.错误);
                    }
                }
                else
                {
                    if (accountType == 11 || accountType == 12)
                    {
                        JScript.AlertMsgOne(this, "银行名称、持卡人名称、银行卡号不能为空!", JScript.IconOption.错误, 2500);
                    }
                    else
                    {
                        JScript.AlertMsgOne(this, "中金账户名称、中金账户号码不能为空!", JScript.IconOption.错误, 2500);
                    }
                }
            }
        }
    }