Exemplo n.º 1
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") + "'); }");
        }
    }
Exemplo n.º 2
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") + "'
        }
    }
Exemplo n.º 3
0
 public void Bind()
 {
     if (KeyID > 0)
     {
         Hi.Model.PAY_PrePayment Ppmodel = PAbll.GetModel(KeyID);
         this.lbldis.InnerText        = Common.GetDis(Ppmodel.DisID, "DisName");
         this.lblcreatetime.InnerText = Convert.ToDateTime(Ppmodel.CreatDate).ToString("yyyy-MM-dd");
         this.lblauditstate.InnerText = Common.GetNameBYPreStart(Ppmodel.AuditState);
         this.lblcreateuser.InnerText = Common.GetUserName(Ppmodel.CrateUser);
         this.lblprice.InnerText      = Convert.ToDecimal(Ppmodel.price).ToString("0.00");
         this.lblpaytype.InnerText    = Common.GetPrePayStartName(Ppmodel.PreType);
         this.lblRemark.InnerText     = Ppmodel.vdef1;
         this.Audit.Visible           = Ppmodel.AuditState == 2 ? false : true;
     }
 }
Exemplo n.º 4
0
 public void rptOrder_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         Hi.Model.PAY_PrePayment drv = (Hi.Model.PAY_PrePayment)e.Item.DataItem;
         ta += Convert.ToDecimal(drv.price);
     }
     if (e.Item.ItemType == ListItemType.Footer)
     {
         if (e.Item.FindControl("total") != null)
         {
             Label tol = (Label)e.Item.FindControl("total");
             tol.Text = string.Format("{0}", ta.ToString("N"));
         }
     }
 }
Exemplo n.º 5
0
    /// <summary>
    /// 审核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAudit_Click(object sender, EventArgs e)
    {
        Hi.Model.PAY_PrePayment PAmodel = this.PAbll.GetModel(KeyID);

        if (PAmodel != null)
        {
            if (PAmodel.AuditState != Convert.ToInt32(Enums.PrePayState.已审))
            {
                PAmodel.AuditState = 2;
                PAmodel.IsEnabled  = 1;
                PAmodel.ID         = KeyID;
                if (PAbll.Update(PAmodel))
                {
                    ////sum代理商全部补录,冲正金额
                    //decimal sums = new Hi.BLL.PAY_PrePayment().sums(PAmodel.DisID,PAmodel.CompID);

                    ////修改代理商的企业钱包金额
                    ////调用model,对属性进行赋值
                    //Hi.Model.BD_Distributor dismodel = new Hi.BLL.BD_Distributor().GetModel(PAmodel.DisID);
                    //dismodel.DisAccount = sums;
                    //dismodel.ID = PAmodel.DisID;
                    ////调用修改方法
                    //Hi.BLL.BD_Distributor disupdate = new Hi.BLL.BD_Distributor();
                    //bool disup = disupdate.Update(dismodel);

                    //if (disup)
                    //{

                    Utils.AddSysBusinessLog(this.CompID, "PrePayment", KeyID.ToString(), "预收款补录审核", "");
                    JScript.AlertMsgOne(this, "操作成功!", JScript.IconOption.笑脸);
                    Bind();

                    // }
                }
            }
            else
            {
                JScript.AlertMsgOne(this, "数据状态不正确,不能进行审核!", JScript.IconOption.错误);
            }
        }
        else
        {
            JScript.AlertMsgOne(this, "数据不存在!", JScript.IconOption.错误);
        }
    }
Exemplo n.º 6
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");
        }
    }
Exemplo n.º 7
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);
    }
Exemplo n.º 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.PAY_PrePayment model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.PAY_PrePayment model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 10
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);
    }
Exemplo n.º 11
0
    /// <summary>
    /// 新建补录企业钱包
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //定义变量
        string txtPayCreateDis   = string.Empty;
        string txtPayCreatePrice = string.Empty;
        //string txtPayCreateDate = string.Empty;
        string txtPayCreateType   = string.Empty;
        string txtPayCreateRemark = string.Empty;

        //获取输入的值
        txtPayCreateDis   = Common.NoHTML(this.txtPayCreateDis.Value.Trim().ToString());
        txtPayCreatePrice = Common.NoHTML(this.txtPayCreatePrice.Value.Trim().ToString());
        //txtPayCreateDate = this.txtPayCreateDate.Value.Trim().ToString();
        txtPayCreateType   = Common.NoHTML(this.txtPayCreateType.Value.Trim().ToString());
        txtPayCreateRemark = Common.NoHTML(this.txtPayCreateRemark.Value.Trim().ToString());
        //调用model,对属性进行赋值
        Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.Model.PAY_PrePayment();
        prepaymentmodel.CompID     = 1;
        prepaymentmodel.DisID      = Convert.ToInt32(txtPayCreateDis);
        prepaymentmodel.Start      = 1;
        prepaymentmodel.PreType    = Convert.ToInt32(txtPayCreateType);
        prepaymentmodel.price      = Convert.ToDecimal(txtPayCreatePrice);
        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      = txtPayCreateRemark;
        //调用保存方法
        Hi.BLL.PAY_PrePayment prepaymentsave = new Hi.BLL.PAY_PrePayment();
        int reslut = prepaymentsave.Add(prepaymentmodel);

        //判断返回值int
        if (reslut > 0)
        {
            //向企业钱包表中添加数据的时候,向日志表中添加数据

            /*Hi.Model.PAY_PaymentLog paymentlog = new Hi.Model.PAY_PaymentLog();
             * paymentlog.CompID = 1;
             * //paymentlog.OrgCode = 0;
             * //paymentlog.MarkNumber = 0;
             * paymentlog.Price = Convert.ToDecimal(txtPayCreatePrice);
             * //paymentlog.PayorgCode = ;
             * //paymentlog.PayCode = ;
             * paymentlog.DisID = Convert.ToInt32(txtPayCreateDis);
             * paymentlog.PayTime = DateTime.Now;
             * paymentlog.Remark = txtPayCreateRemark;
             * paymentlog.CreateUser = 1;
             * paymentlog.CreateDate = DateTime.Now;
             * //调用保存方法
             * Hi.BLL.PAY_PaymentLog paymentlogSave = new Hi.BLL.PAY_PaymentLog();
             * int reslutLog = paymentlogSave.Add(paymentlog);*/

            //sum代理商全部补录,冲正金额
            //decimal sums = prepaymentsave.sums(txtPayCreateDis);
            //修改代理商的企业钱包金额
            //调用model,对属性进行赋值
            //Hi.Model.BD_Distributor dismodel = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(txtPayCreateDis));
            //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('" + ("PayCreateList.aspx") + "'); }");
        }
        else
        {
            JScript.AlertMethod(this, "补录失败", JScript.IconOption.错误, "function (){ location.replace('" + ("PayCreateList.aspx") + "'); }");
        }
    }
Exemplo n.º 12
0
    protected void btnTx1376_Click(object sender, EventArgs e)
    {
        try
        {
            Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment();
            Hi.Model.PAY_Payment    payM    = new Hi.Model.PAY_Payment();
            if (Request.QueryString["KeyID"] == "")
            {
                KeyID = 0;
            }
            else
            {
                KeyID = Convert.ToInt32(Common.DesDecrypt(Request.QueryString["KeyID"].ToString(), Common.EncryptKey));
            }

            string  phoneCode = this.txtPhoneNum.Value; //检验码
            decimal price     = 0;                      //使用企业钱包金额
            int     hidPay    = 0;                      //支付表ID
            if (ViewState["payid"] == null || ViewState["payid"] == "")
            {
                //JScript.ShowAlert(this, "数据异常!", "$('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100);");
                Tx1376ErrResult("数据异常!");
                return;
            }
            hidPay             = Convert.ToInt32(ViewState["payid"]);
            ViewState["payid"] = null;
            payM = new Hi.BLL.PAY_Payment().GetModel(hidPay);
            int hidPrepay = KeyID;//企业钱包表ID
            if (hidPrepay <= 0)
            {
                //JScript.ShowAlert(this, "数据异常!", "$('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100);");
                Tx1376ErrResult("数据异常!");
                return;
            }
            prepayM = new Hi.BLL.PAY_PrePayment().GetModel(Convert.ToInt32(hidPrepay));
            price   = prepayM.price;
            int hidFastPay = Convert.ToInt32(this.hidFastPay.Value);
            int regid      = 0;

            Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog();
            regModel.OrderId    = hidPrepay;
            regModel.Ordercode  = payM.vdef4;// WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(hidPrepay);
            regModel.number     = payM.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     = new Hi.BLL.PAY_FastPayMent().GetModel(hidFastPay).BankID.ToString();
            regModel.CreateUser = this.UserID;
            regModel.CreateDate = DateTime.Now;
            regModel.LogType    = 1376;
            regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);

            if (regid <= 0)
            {
                Tx1376ErrResult("数据异常!");
                return;
            }

            if (WebConfigurationManager.AppSettings["Paytest_zj"] != "1")
            {
                string configPath = WebConfigurationManager.AppSettings["payment.config.path"];
                try
                {
                    PaymentEnvironment.Initialize(configPath);
                }
                catch
                {
                    throw new Exception("支付配置不正确,请联系管理员!");
                }

                string institutionID = WebConfigurationManager.AppSettings["PayOrgCode"];//机构号码

                Tx1376Request tx1376Request = new Tx1376Request();

                tx1376Request.setInstitutionID(institutionID);
                tx1376Request.setOrderNo(payM.vdef4);//WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(hidPrepay)
                tx1376Request.setPaymentNo(new Hi.BLL.PAY_Payment().GetModel(Convert.ToInt32(hidPay)).guid);
                tx1376Request.setSmsValidationCode(phoneCode);

                tx1376Request.process();

                TxMessenger txMessenger = new TxMessenger();
                String[]    respMsg     = txMessenger.send(tx1376Request.getRequestMessage(), tx1376Request.getRequestSignature());

                Tx1376Response tx1376Response = new Tx1376Response(respMsg[0], respMsg[1]);

                try
                {
                    Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid);
                    regM.PlanMessage   = tx1376Request.getRequestPlainText();
                    regM.Start         = tx1376Response.getCode();
                    regM.ResultMessage = tx1376Response.getMessage();
                    new Hi.BLL.PAY_RegisterLog().Update(regM);
                    Hi.Model.PAY_Payment payModel = new Hi.BLL.PAY_Payment().GetModel(hidPay);
                    payM.PayDate          = DateTime.Now;
                    payModel.ts           = DateTime.Now;
                    payModel.verifystatus = tx1376Response.getVerifyStatus();
                    payModel.status       = tx1376Response.getStatus();
                    new Hi.BLL.PAY_Payment().Update(payModel);
                }
                catch { }
                if (!"2000".Equals(tx1376Response.getCode()))
                {
                    Tx1376ErrResult(tx1376Response.getMessage());
                    return;
                }
                int VerifyStatus = tx1376Response.getVerifyStatus();
                int Status       = tx1376Response.getStatus();
                if (VerifyStatus != 40 || Status != 20)//VerifyStatus = 40 验证码验证成功,Status = 20 支付成功
                {
                    if (Status == 10)
                    {
                        //中金:支付处理中,钱会从账户中扣除,第二天会退回到账户中。
                        Tx1376ErrResult("代扣失败");
                        return;
                    }
                    Tx1376ErrResult(tx1376Response.getResponseMessage());
                    return;
                }
            }
            else
            {
                try
                {
                    Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid);
                    regM.PlanMessage   = "";
                    regM.Start         = "2000";
                    regM.ResultMessage = "OK.";
                    new Hi.BLL.PAY_RegisterLog().Update(regM);
                    Hi.Model.PAY_Payment payModel = new Hi.BLL.PAY_Payment().GetModel(hidPay);
                    payM.PayDate          = DateTime.Now;
                    payModel.ts           = DateTime.Now;
                    payModel.verifystatus = 40;
                    payModel.status       = 20;
                    new Hi.BLL.PAY_Payment().Update(payModel);
                }
                catch { }
            }

            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, hidPay, sqlTrans);
                prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, hidPrepay, sqlTrans);
                if (pay > 0 && prepay > 0)
                {
                    sqlTrans.Commit();
                }
                else
                {
                    sqlTrans.Rollback();
                }
            }
            catch
            {
                pay    = 0;
                prepay = 0;
                sqlTrans.Rollback();
            }
            finally
            {
                con.Close();
            }
            if (pay <= 0 || prepay <= 0)
            {
                Tx1376ErrResult("支付成功,但修改支付状态失败,请联系系统管理员,勿重复操作!");
                return;
            }
            Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("3", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey), false);
            return;
        }
        catch (Exception ex)
        {
            JScript.AlertMethod(this, ex.Message, JScript.IconOption.错误, "function (){ $('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100); }");
            return;
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// 审核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAudit_Click(object sender, EventArgs e)
    {
        #region  接口字段整理

        int    ordID     = 0;            //订单Id
        string ReceiptNo = string.Empty; //订单号
        string guid      = string.Empty; //流水号
        string remark    = string.Empty; //订单备注

        //-----银行信息
        string orgcode              = string.Empty; //机构代码
        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
        #endregion



        Hi.Model.PAY_PrePayment PAmodel = this.PAbll.GetModel(KeyID);



        if (PAmodel != null)
        {
            if (PAmodel.AuditState != Convert.ToInt32(Enums.PrePayState.已审) && (Convert.ToInt32(Enums.PrePayType.企业钱包冲正) == PAmodel.PreType || Convert.ToInt32(Enums.PrePayType.企业钱包补录) == PAmodel.PreType))
            {
                PAmodel.AuditState = 2;
                PAmodel.IsEnabled  = 1;
                PAmodel.ID         = KeyID;
                if (PAbll.Update(PAmodel))
                {
                    #region//修改代理商的企业钱包金额---作废
                    ////sum代理商全部补录,企业钱包冲正金额
                    //decimal sums = new Hi.BLL.PAY_PrePayment().sums(PAmodel.DisID, PAmodel.CompID);


                    ////调用model,对属性进行赋值
                    //Hi.Model.BD_Distributor dismodel = new Hi.BLL.BD_Distributor().GetModel(PAmodel.DisID);
                    //dismodel.DisAccount = sums;
                    //dismodel.ID = PAmodel.DisID;
                    ////调用修改方法
                    //Hi.BLL.BD_Distributor disupdate = new Hi.BLL.BD_Distributor();
                    //bool disup = disupdate.Update(dismodel);
                    #endregion

                    //if (disup)
                    //{
                    if (Convert.ToInt32(Enums.PrePayType.企业钱包冲正) == PAmodel.PreType)
                    {
                        //系统日志记录
                        Utils.AddSysBusinessLog(this.CompID, "PrePayment", KeyID.ToString(), "企业钱包冲正审核", PAmodel.vdef1);
                    }
                    else
                    {
                        //系统日志记录
                        Utils.AddSysBusinessLog(this.CompID, "PrePayment", KeyID.ToString(), "企业钱包补录审核", PAmodel.vdef1);
                    }

                    JScript.AlertMsgOne(this, "操作成功!", JScript.IconOption.笑脸);
                    Bind();
                    // }
                }
            }
            #region  结算作废代码----
            //if (PAmodel.AuditState != Convert.ToInt32(Enums.PrePayState.已审) && Convert.ToInt32(Enums.PrePayType.转账汇款) == PAmodel.PreType)
            //{
            //    ordID = KeyID;//订单编号

            //    DataTable dt_order = new Hi.BLL.PAY_PrePayment().GetdataTable_pre(1, " and PAY_PrePayment.ID =" + ordID);

            //    if (dt_order.Rows.Count <= 0)
            //    {
            //        JScript.ShowAlert(this, "支付表中没有相关的记录,无法进行审批结算!");
            //        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(2, " and PAY_PaymentAccountdtl.DisID=" + disID, 0);//结算接口,银行信息--已代理商为核心
            //        DataTable dt_bank_comp = new Hi.BLL.PAY_PrePayment().GetdataTable(3, " and PAY_PaymentAccount.CompID=" + compID, 0);//结算接口,银行信息--已企业为主,


            //        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 =  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.ShowAlert(this, "无法进行收款结算,请在【结算账户管理】中维护收款帐号信息!");
            //            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])));
            //                    //string plantext= tx1341Request.getRequestPlainText;
            //                    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()))
            //                    {
            //                        //修改转账汇款状态
            //                        Hi.Model.PAY_PrePayment PrepaymentModel = new Hi.BLL.PAY_PrePayment().GetModel(ordID);
            //                        PrepaymentModel.AuditState = 2;//修改审批状态
            //                        PrepaymentModel.vdef2 ="1"; //支付状态改为已结算
            //                        bool fal = new Hi.BLL.PAY_PrePayment().Update(PrepaymentModel);
            //                        if (fal)
            //                        {
            //                            //系统日志记录
            //                            Utils.AddSysBusinessLog(this.CompID, "PrePayment", ordID.ToString(), "转账汇款审核", PAmodel.vdef1);

            //                            JScript.ShowAlert(this, "操作成功!");
            //                        }

            //                        //日志记录 接口返回的信息
            //                        paylogmodel.Start = tx134xResponse.getCode();
            //                        paylogmodel.ResultMessage = tx134xResponse.getMessage();
            //                        paylogmodel.ID = paylogID;
            //                        bool payLog_update = paylogbll.Update(paylogmodel);
            //                        if (payLog_update)
            //                            Utils.AddSysBusinessLog(this.CompID, "PrePayment", ordID.ToString(), "转账汇款结算", PAmodel.vdef1);

            //                        #region//修改代理商的企业钱包金额--作废

            //                        ////sum代理商全部补录,企业钱包冲正金额
            //                        //decimal sums = new Hi.BLL.PAY_PrePayment().sums(PAmodel.DisID, PAmodel.CompID);
            //                        ////调用model,对属性进行赋值
            //                        //Hi.Model.BD_Distributor dismodel = new Hi.BLL.BD_Distributor().GetModel(PAmodel.DisID);
            //                        //dismodel.DisAccount = sums;
            //                        //dismodel.ID = PAmodel.DisID;
            //                        ////调用修改方法
            //                        //Hi.BLL.BD_Distributor disupdate = new Hi.BLL.BD_Distributor();
            //                        //bool disup = disupdate.Update(dismodel);

            //                        #endregion
            //                        Bind();
            //                    }


            //                    else
            //                    {
            //                        Utils.AddSysBusinessLog(this.CompID, "PrePayment", ordID.ToString(),strs , PAmodel.vdef1);

            //                        JScript.ShowAlert(this, "系统繁忙,请稍后再试!");
            //                    }

            //                }
            //                catch (Exception ex)
            //                {
            //                    throw ex;
            //                }
            //            }

            //        }
            //    }
            //}
            #endregion
            //else
            //{
            //    Utils.AddSysBusinessLog(this.CompID, "PrePayment", ordID.ToString(), "数据状态不正确,不能进行审核!", PAmodel.vdef1);

            //    JScript.ShowAlert(this, "数据状态不正确,不能进行审核!");
            //}
        }
        else
        {
            Utils.AddSysBusinessLog(this.CompID, "PrePayment", ordID.ToString(), "数据不存在!", PAmodel.vdef1);

            JScript.AlertMsgOne(this, "数据不存在!", JScript.IconOption.错误);
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// 确认退款
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReturnMoney_Click(object sender, EventArgs e)
    {
        Hi.Model.DIS_OrderReturn OrderReturnModel = OrderReturnBll.GetModel(KeyID);

        if (OrderReturnModel != null)
        {
            if (OrderReturnModel.ReturnState == (int)Enums.AuditState.已审)
            {
                Hi.Model.DIS_Order OrderModel = new Hi.BLL.DIS_Order().GetModel(OrderReturnModel.OrderID);

                if (OrderModel == null)
                {
                    JScript.AlertMsgOne(this, "订单信息有误!", JScript.IconOption.错误, 2500);
                    return;
                }
                if (OrderModel.OState == (int)Enums.OrderState.退货处理 && OrderModel.ReturnState == (int)Enums.ReturnState.申请退货)
                {
                    OrderModel.OState      = (int)Enums.OrderState.已退货;
                    OrderModel.PayState    = (int)Enums.PayState.已退款;
                    OrderModel.ReturnState = (int)Enums.ReturnState.退货退款;
                    OrderModel.ts          = DateTime.Now;
                    OrderModel.modifyuser  = this.UserID;

                    //OrderReturnModel.ReturnState = (int)Enums.AuditState.已完结;
                    //OrderReturnModel.ts = DateTime.Now;
                    //OrderReturnModel.modifyuser = this.UserID;
                    //退货审确认退款
                    //if (OrderInfoType.ReturnOrderUpdate(OrderReturnModel, OrderModel) > 0)
                    //{

                    #region   把退款金额变为代理商的企业钱包金额
                    int           order  = 0;
                    int           prepay = 0;
                    SqlConnection con    = new SqlConnection(LocalSqlServer);
                    con.Open();
                    SqlTransaction sqlTrans = con.BeginTransaction();

                    Hi.Model.PAY_PrePayment PrepayModel = new Hi.Model.PAY_PrePayment();
                    Hi.BLL.PAY_PrePayment   PrepayBLL   = new Hi.BLL.PAY_PrePayment();
                    PrepayModel.CompID    = OrderModel.CompID;
                    PrepayModel.DisID     = OrderModel.DisID;
                    PrepayModel.OrderID   = OrderModel.ID;
                    PrepayModel.Start     = 1;
                    PrepayModel.PreType   = 4;
                    PrepayModel.price     = OrderModel.PayedAmount; //已支付金额
                    PrepayModel.Paytime   = DateTime.Now;
                    PrepayModel.CrateUser = this.UserID;
                    PrepayModel.CreatDate = DateTime.Now;
                    PrepayModel.OldId     = 0;

                    PrepayModel.AuditState = 2;
                    PrepayModel.IsEnabled  = 1;
                    PrepayModel.AuditUser  = this.UserID;
                    PrepayModel.dr         = 0;
                    PrepayModel.ts         = DateTime.Now;

                    try
                    {
                        order  = new Hi.BLL.DIS_Order().UpdateOrderByggh(con, OrderModel, sqlTrans, KeyID, (int)Enums.AuditState.已完结);
                        prepay = new Hi.BLL.PAY_PrePayment().InsertPrepay(con, PrepayModel, sqlTrans);
                        sqlTrans.Commit();
                    }
                    catch
                    {
                        order  = 0;
                        prepay = 0;
                        sqlTrans.Rollback();
                    }
                    finally
                    {
                        con.Close();
                    }
                    #endregion

                    if (prepay > 0 && order > 0)
                    {
                        //代理商手机号
                        string Phone = Common.GetDis(OrderModel.DisID, "Phone");
                        string msg   = "您的订单:" + OrderModel.ReceiptNo + "退货金额已退回您的企业钱包账户,请查收![ " + Common.GetCompValue(CompID, "CompName") + "]";
                        //退款向代理商推送信息提示
                        Common.GetPhone(Phone, msg);

                        Utils.AddSysBusinessLog(this.CompID, "Order", OrderReturnModel.OrderID.ToString(), "退货退款确认", "");
                    }
                    string type = Request.QueryString["type"] + "";
                    Response.Redirect("OrderReturnInfo.aspx?KeyID=" + Common.DesEncrypt(this.KeyID.ToString(), Common.EncryptKey) + "&go=2&type=" + type);

                    //Bind();
                    //Response.Write("<script language=\"javascript\">window.parent.AuditReturn(" + KeyID + ");</script>");
                    //}
                }
                else
                {
                    JScript.AlertMsgOne(this, "订单信息有误!", JScript.IconOption.错误, 2500);
                    return;
                }
            }
            else
            {
                JScript.AlertMsgOne(this, "订单状态有误!", JScript.IconOption.错误, 2500);
                return;
            }
        }
    }
Exemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sPara = GetRequestPost();

        Common.CatchInfo("调用成功", sPara.ToString());

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            //Notify aliNotify = new Notify();
            Notify aliNotify    = new Notify();
            bool   verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);

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

                //商户订单号
                string out_trade_no = Request.Form["out_trade_no"];

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

                //交易状态
                string trade_status = Request.Form["trade_status"];

                //买家账号
                string buyer_email = Request.Form["buyer_email"];

                //支付金额
                string price = Request.Form["total_fee"];

                if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_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  = 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 == 1)
                    {
                        Console.WriteLine("该支付记录状态已经修改成功,请不要重复操作!");
                    }

                    //!!!支付成功 !!!
                    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)
                            {
                                Common.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + prices), "订单支付", "", orderModel.CreateUserID);
                            }
                        }
                        catch { }
                        if (orderModel.Otype == (int)Enums.OType.推送账单)
                        {
                            Common.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
                        {
                            Common.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
                        {
                            MsgSend.Jpushdega jpushdega = new MsgSend.Jpushdega(new MsgSend().GetWxService);
                            jpushdega.BeginInvoke("2", orderModel.ID.ToString(), "1", prepayPrice + prices, null, null);
                            //new MsgSend().GetWxService("2", orderModel.ID.ToString(), "1", prepayPrice + prices);
                        }
                        catch { }

                        //Response.Write("success");  //请不要修改或删除
                        //打印页面
                        //Response.Write("支付成功<br />");
                        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//验证失败
            {
                Response.Write("fail");
            }
        }
        //else
        //{
        //    Response.Write("无通知参数");
        //    Response.Redirect("ErrorPay.aspx?type=2&OrderCode=" + Request.QueryString["out_trade_no"]);
        //}
    }
Exemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int orderid = 0;

        if (!IsPostBack)
        {
            try
            {
                // 1.取得参数
                if (Request.Form["hidOid"] == "")
                {
                    orderid = 0;
                }
                else
                {
                    orderid = Common.DesDecrypt(Request.Form["hidOid"], Common.EncryptKey).ToInt(0);
                    KeyID   = orderid;
                }
                if (!Common.PageDisOperable("Order", orderid, this.DisID))
                {
                    Response.Redirect("../../NoOperable.aspx", true);
                    return;
                }

                decimal txtPayOrder = Convert.ToDecimal(Request.Form["hidPayOrder"]); //本次支付总金额
                decimal price       = Convert.ToDecimal(Request.Form["hidPrice"]);    //使用企业钱包金额
                int     yfk         = Convert.ToInt32(Request.Form["hidIsPre"]);      //是否使用企业钱包  1:是  0:否
                int     isDBPay     = Convert.ToInt32(Request.Form["hidIsDBPay"]);    //是否是担保支付  1:是  0:否
                string  bankid      = Convert.ToString(Request.Form["hidBankNo"]);    //银行编号
                string  AccountType = Request.Form["hidAccountType"];                 //账户类型
                string  payPas      = Convert.ToString(Request.Form["hidPayPas"]);    //预付款密码

                Hi.Model.BD_Distributor disModel = new Hi.BLL.BD_Distributor().GetModel(this.DisID);

                Hi.Model.DIS_Order disOrderMOdel = new Hi.BLL.DIS_Order().GetModel(orderid);

                if (disModel == null)
                {
                    err = true;
                    ErrMessage("数据异常");
                    return;
                }

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

                if (yfk == 1)
                {
                    if (payPas == null || payPas.Trim().ToString() == "")
                    {
                        err = true;
                        ErrMessage("企业钱包密码不能为空");
                        return;
                    }
                    payPas = payPas.Trim().ToString();
                    if (password == Util.md5("123456"))
                    {
                        err = true;
                        ErrMessage("请先修改企业钱包支付密码");
                        return;
                    }
                    else
                    {
                        if (payPas == "")
                        {
                            //string Josn = "{\"error\":\"1\",\"msg\":\"密码不能为空!\"}";
                            err = true;
                            ErrMessage("密码不能为空");

                            return;
                        }
                    }
                }

                decimal payPrice = 0;
                if (txtPayOrder == 0)
                {
                    err = true;
                    ErrMessage("支付金额不能为0");

                    return;
                }
                if (yfk == 1 && txtPayOrder < price)
                {
                    err = true;
                    ErrMessage("使用企业钱包大于支付金额!");
                    return;
                }
                if (yfk == 1)
                {
                    payPrice = txtPayOrder - price;
                }
                else
                {
                    payPrice = txtPayOrder;
                }
                if (orderid <= 0)
                {
                    //string Josn = "{\"error\":\"1\",\"msg\":\"操作有误!\"}";
                    err = true;
                    ErrMessage("数据有误");

                    return;
                }
                Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(orderid);
                if (orderModel == null)
                {
                    err = true;
                    ErrMessage("数据有误");

                    return;
                }
                if (txtPayOrder > orderModel.AuditAmount + orderModel.OtherAmount - orderModel.PayedAmount)
                {
                    err = true;
                    ErrMessage("支付金额大于未支付金额,不能支付!");
                    return;
                }
                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.推送账单)
                    {
                        err = true;
                        ErrMessage("账单异常,不能支付");
                    }
                    else
                    {
                        err = true;
                        ErrMessage("订单异常,不能支付");
                    }
                    return;
                }

                int prepayid = 0;

                if (yfk == 1 && price > 0)
                {
                    //企业钱包处理
                    if (sumPrice < price)
                    {
                        err = true;
                        ErrMessage("企业钱包余额不足");

                        return;
                    }
                    if (disModel.Paypwd != Util.md5(payPas))
                    {
                        err = true;
                        ErrMessage("支付密码不正确");

                        return;
                    }
                    Hi.Model.PAY_PrePayment prepayModel = new Hi.Model.PAY_PrePayment();
                    prepayModel.CompID     = disOrderMOdel.CompID;
                    prepayModel.DisID      = disModel.ID;
                    prepayModel.OrderID    = orderid;
                    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, orderid, 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(disOrderMOdel.CompID, "Order", orderid.ToString(), "账单支付", "支付:" + price.ToString("0.00") + "元(企业钱包支付)", this.UserID.ToString());
                                }
                                else
                                {
                                    Utils.AddSysBusinessLog(disOrderMOdel.CompID, "Order", orderid.ToString(), "订单支付", "支付:" + price + "元(企业钱包支付)", this.UserID.ToString());
                                }
                                if (orderModel.Otype != 9)
                                {
                                    OrderInfoType.AddIntegral(disOrderMOdel.CompID, disOrderMOdel.DisID, "1", 1, orderid, price, "订单支付", "", this.UserID);
                                }
                                new Common().GetWxService("2", orderid.ToString(), "1", price);
                            }
                            catch (Exception ex) { throw ex; }

                            if (orderModel.Otype == (int)Enums.OType.推送账单)
                            {
                                err = true;//阻止进入网银支付
                                Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false);
                            }
                            else
                            {
                                err = true;//阻止进入网银支付
                                Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("1", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false);
                            }
                            return;
                        }
                        else
                        {
                            err = true;
                            ErrMessage("支付失败");
                            return;
                        }
                    }
                }

                if (payPrice <= 0)
                {
                    err = true;
                    ErrMessage("数据有误");
                    return;
                }


                #region     计算支付手续费 start
                string  sxfsq    = "-1";
                decimal sxf      = 0;
                decimal comp_sxf = 0;//收费方是厂商是,为了不改变支付金额,故声明此变量来记录,厂商手续费。
                // 获取手续费 begin
                string[] Json = Common.GetSxf(disOrderMOdel.CompID, AccountType, bankid, payPrice);

                string strMsg = Json[2].ToString();
                if (!string.IsNullOrEmpty(strMsg))
                {
                    ErrMessage(strMsg);
                    return;
                }
                else
                {
                    sxfsq    = Json[1].ToString();
                    sxf      = Convert.ToDecimal(Json[0]);
                    comp_sxf = Convert.ToDecimal(Json[3]);
                }
                // 获取手续费 end


                //支付总金额(含手续费)
                decimal UNIT = 0.01M;
                payPrice = payPrice + Common.Round(sxf, UNIT);

                #endregion  计算支付手续费 end


                int payid = 0;
                int regid = 0;
                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      = orderid;
                payModel.DisID        = this.DisID;
                payModel.Type         = isDBPay;
                payModel.PayUser      = disModel.DisName;
                payModel.PayPrice     = payPrice;
                payModel.IsAudit      = 2;
                payModel.guid         = Common.Number_repeat(guid);
                payModel.vdef3        = "1";
                payModel.vdef4        = orderNo;
                payModel.CreateDate   = DateTime.Now;
                payModel.CreateUserID = this.UserID;
                payModel.ts           = DateTime.Now;
                payModel.modifyuser   = this.UserID;
                //判断账户类型,判断支付渠道,然后赋值
                if (AccountType == "11")
                {
                    if (bankid == "888")
                    {
                        payModel.Channel = "2";
                    }
                    else
                    {
                        payModel.Channel = "3";
                    }
                }//信用卡支付
                else if (AccountType == "13")
                {
                    payModel.Channel = "8";
                }
                else//网银支付
                {
                    payModel.Channel = "4";
                }

                payModel.State = Convert.ToInt32(sxfsq);//手续费收取方

                if (sxfsq.Equals("2"))
                {
                    payModel.vdef5 = comp_sxf.ToString("0.00");
                }
                else
                {
                    payModel.vdef5 = sxf.ToString("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    = orderid;
                regModel.Ordercode  = orderNo;// orderNo + payid.ToString();
                regModel.number     = payModel.guid;
                regModel.Price      = payPrice;
                regModel.Payuse     = "订单支付";
                regModel.PayName    = disModel.DisName;
                regModel.DisID      = disid;
                regModel.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                regModel.Remark     = orderModel.Remark;
                regModel.DisName    = new Hi.BLL.BD_Company().GetModel(disOrderMOdel.CompID).CompName;
                regModel.BankID     = bankid;
                regModel.CreateUser = this.UserID;
                regModel.CreateDate = DateTime.Now;
                regModel.LogType    = 1311;
                regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);
                if (payid <= 0 || regid <= 0)
                {
                    err = true;
                    ErrMessage("数据有误");
                    return;
                }
                string configPath = WebConfigurationManager.AppSettings["payment.config.path"];
                try
                {
                    PaymentEnvironment.Initialize(configPath);
                }
                catch (Exception ex)
                {
                    //string Josn = "{\"error\":\"1\",\"msg\":\"支付配置有误,请联系系统管理员!\"}";
                    err = true;
                    ErrMessage("支付配置有误,请联系系统管理员");

                    return;
                }

                String institutionID = WebConfigurationManager.AppSettings["PayOrgCode"]; //机构代码

                long   amount          = Convert.ToInt64(payPrice * 100);                 //支付金额(单位:分)
                long   fee             = 0;
                String usage           = "支付订单";
                String remark          = "订单支付";
                String notificationURL = "";
                //"http://www.my1818.com/Handler/ReceiveNoticePage.ashx";//Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port +

                if (WebConfigurationManager.AppSettings["PayType"] == "0")
                {
                    notificationURL = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/Handler/ReceiveNoticePage.ashx";
                }
                // notificationURL = "https://www.yibanmed.com/Handler/ReceiveNoticePage.ashx";
                else
                {
                    notificationURL = "https://www.yibanmed.com/Handler/ReceiveNoticePage.ashx";//回调页面地址
                }
                String payees = new Hi.BLL.BD_Company().GetModel(disOrderMOdel.CompID).CompName;

                //判断支付接口
                string Pay_type = WebConfigurationManager.AppSettings["PayType"];
                String bankID   = string.Empty;
                if (Pay_type == "0") //测试接口
                {
                    bankID = "700";  //bankid;//
                }
                else
                {
                    bankID = bankid;//正式接口
                }
                int accountType = Convert.ToInt32(AccountType);

                // 2.创建交易请求对象
                Tx1311Request tx1311Request = new Tx1311Request();
                tx1311Request.setInstitutionID(institutionID);     //机构号码
                tx1311Request.setOrderNo(orderNo);                 //订单号orderNo + payid.ToString()
                tx1311Request.setPaymentNo(payModel.guid);         //支付交易流水号
                tx1311Request.setAmount(amount);                   //支付金额 单位分
                tx1311Request.setFee(fee);                         //支付服务手续费 单位分
                tx1311Request.setPayerID("");                      //付款人注册ID
                tx1311Request.setPayerName("");                    //付款方名称
                tx1311Request.setUsage(usage);                     //资金用途
                tx1311Request.setRemark(remark);                   //备注
                tx1311Request.setNotificationURL(notificationURL); //机构接收支付通知的URL
                tx1311Request.addPayee("");                        //收款方名称

                if (accountType == 13)
                {
                    tx1311Request.setAccountType(11); //付款方帐号类型
                    tx1311Request.setCardType("02");  //银行卡类型(01=借记卡、02=贷记卡)
                }
                else if (accountType == 11)
                {
                    tx1311Request.setAccountType(accountType); //付款方帐号类型
                    tx1311Request.setCardType("01");           //银行卡类型(01=借记卡、02=贷记卡)
                }
                else if (accountType == 12)
                {
                    tx1311Request.setAccountType(accountType); //付款方帐号类型
                }
                tx1311Request.setBankID(bankID);               //付款银行标识


                // 3.执行报文处理
                tx1311Request.process();
                try
                {
                    Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid);
                    regM.PlanMessage = tx1311Request.getRequestPlainText();
                    new Hi.BLL.PAY_RegisterLog().Update(regM);
                }
                catch (Exception ex) { throw ex; }

                //跳转的url地址
                HttpContext.Current.Items["action"] = PaymentEnvironment.PaymentURL;
                //中金返回信息
                HttpContext.Current.Items["message"] = tx1311Request.getRequestMessage();
                //中金签名信息
                HttpContext.Current.Items["signature"] = tx1311Request.getRequestSignature();
            }
            catch (Exception ex)
            {
                err = true;
                ErrMessage(ex.Message);
                return;
            }
            finally
            {
                if (!err)
                {
                    Context.Server.Transfer("DoSubmit.aspx", false);
                }
            }
        }
    }
Exemplo n.º 17
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;
        }
        txtPayCorrectDis    = Common.NoHTML(this.hidDisUserID.Value);     // this.DisListID.Disid;//获取代理商ID
        txtPayCorrectRemark = Common.NoHTML(this.txtRemark.Value.Trim()); //获取备注
        int compid = CompID;
        int disID  = 0;

        if (this.CompUser.DisID != 0)
        {
            disID = this.CompUser.DisID;
        }
        //判断冲正金额是否大于企业钱包金额
        decimal nowprePrice = new Hi.BLL.PAY_PrePayment().sums(Convert.ToInt32(txtPayCorrectDis), compid);
        decimal czprice     = Convert.ToDecimal(txtPayCorrectPrice);

        if (czprice > nowprePrice)
        {
            JScript.AlertMethod(this, "操作失败,冲正金额" + czprice + " 大于企业钱包余额" + nowprePrice.ToString("0.00"), JScript.IconOption.错误, "function (){ location.replace('" + ("PayCorrectAdd.aspx?UID=" + Common.DesEncrypt(txtPayCorrectDis.ToString(), Common.EncryptKey)) + "'); }");
            return;
        }


        //调用model,对属性进行赋值
        Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.Model.PAY_PrePayment();
        prepaymentmodel.CompID     = compid;
        prepaymentmodel.PreType    = 3;
        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;
        //调用保存方法
        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(), "企业钱包冲正新增", "");
            // JScript.AlertMsg(this, "操作成功", "PayCorrectInfo.aspx?KeyID=" + reslut);
            Response.Redirect("PayCorrectInfo.aspx?KeyID=" + Common.DesEncrypt(reslut.ToString(), Common.EncryptKey));
        }
        else
        {
            JScript.AlertMethod(this, "操作失败!", JScript.IconOption.哭脸, "function (){ location.replace('" + ("PayCorrectList.aspx") + "'); }");
        }
    }
Exemplo n.º 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();
        }
    }
Exemplo n.º 19
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Hi.Model.DIS_Order orderone = new Hi.BLL.DIS_Order().GetModel(Convert.ToInt32(this.hidordid.Value));
        if (orderone.vdef1 == "1")
        {
            JScript.AlertMethod(this, "此账单已补录!", JScript.IconOption.错误, "function (){ location.replace('" + ("PayOrderList.aspx") + "'); }");
        }
        else
        {
            //定义变量
            string txtPayCorrectDis   = string.Empty;
            string txtPayCorrectPrice = string.Empty;
            //string txtPayCorrectDate = string.Empty;
            string txtPayCorrectType   = string.Empty;
            string txtPayCorrectRemark = string.Empty;
            //获取收款补录输入的数据
            txtPayCorrectPrice = this.txtPayCorrectPrice.InnerText;
            if (Convert.ToDecimal(txtPayCorrectPrice) <= 0)
            {
                JScript.AlertMethod(this, "操作失败,补录金额不能小于或等于零!", JScript.IconOption.错误, "function (){ location.replace(); }");//'" + ("PayCreateAdd.aspx?UID="+Uid) + "'
                return;
            }


            txtPayCorrectRemark = this.txtRemark.Value.Trim();
            txtPayCorrectDis    = this.hidDisId.Value;//获取代理商ID
            //调用model,对属性进行赋值
            Hi.Model.PAY_PrePayment prepaymentmodel = new Hi.Model.PAY_PrePayment();
            prepaymentmodel.CompID     = this.CompID;
            prepaymentmodel.OrderID    = Convert.ToInt32(this.hidordid.Value);
            prepaymentmodel.PreType    = 8;//账单收款补录
            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;
            //调用保存方法
            Hi.BLL.PAY_PrePayment prepaymentsave = new Hi.BLL.PAY_PrePayment();
            int reslut = prepaymentsave.Add(prepaymentmodel);
            //判断返回值int
            if (reslut > 0)
            {
                Utils.AddSysBusinessLog(this.CompID, "Order", this.hidordid.Value, "账单收款补录新增", prepaymentmodel.vdef1);

                //修改订单为已支付
                Hi.Model.DIS_Order modelorder = new Hi.Model.DIS_Order();
                modelorder             = new Hi.BLL.DIS_Order().GetModel(Convert.ToInt32(this.hidordid.Value));
                modelorder.PayedAmount = Convert.ToDecimal(txtPayCorrectPrice);
                modelorder.PayState    = 2;
                bool fal = new Hi.BLL.DIS_Order().Update(modelorder);
                if (fal)
                {
                    string ordid = this.hidordid.Value;
                    Utils.AddSysBusinessLog(this.CompID, "Order", ordid, "账单核销", "");
                    //int state = Convert.ToInt32(hid_start.Value);
                    //if (state == 2 || state == 0)
                    //{
                    //    //补充发货记录
                    //    Hi.Model.DIS_Order OrderModel = new Hi.BLL.DIS_Order().GetModel(Convert.ToInt32(ordid));
                    //    OrderInfoType.ShopOrder(OrderModel);
                    //    //发货日志+推送
                    //    Utils.AddSysBusinessLog(this.CompID, "Order", ordid, "订单发货", "");
                    //    new Common().GetWxService("0", "4", ordid);//消息推送

                    //}

                    //修改补录标示
                    Hi.Model.DIS_Order OrderModel1 = new Hi.BLL.DIS_Order().GetModel(Convert.ToInt32(ordid));
                    OrderModel1.vdef1 = "1";
                    new Hi.BLL.DIS_Order().Update(OrderModel1);

                    //跳转
                    Response.Redirect("../Order/OrderZdtsInfo.aspx?KeyID=" + ordid + "&go=1");
                }
            }
            else
            {
                JScript.AlertMethod(this, "操作失败!", JScript.IconOption.错误, "function (){ location.replace('" + ("PaymentInfo.aspx&type=0") + "'); }");
            }
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// 申请退款
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    //protected void btnRefund_Click(object sender, EventArgs e)
    //{
    //    Hi.Model.DIS_Order OrderModel = OrderBll.GetModel(KeyID);

    //    if (OrderModel != null)
    //    {
    //        if ((OrderModel.OState == (int)Enums.OrderState.已审) && OrderModel.PayState == (int)Enums.PayState.已支付)
    //        {
    //            string sql = " update [DIS_Order] set [PayState]=" + (int)Enums.PayState.申请退款 + ",[ReturnState]=" + (int)Enums.ReturnState.申请退款 + " where ID=" + KeyID;

    //            if (OrderBll.UpdateOrderState(sql))
    //            {
    //                Utils.AddSysBusinessLog(this.CompID, "Order", KeyID.ToString(), "申请退款", "");
    //                //Bind();
    //                Response.Redirect("OrderInfo.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
    //            }
    //        }
    //        else
    //        {
    //            JScript.ShowAlert(this, "数据状态不正确,不能取消!");
    //        }
    //    }
    //}

    /// <summary>
    /// 支付查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnPayInfo_Click(object sender, EventArgs e)
    {
        Hi.Model.DIS_Order      orderM  = OrderBll.GetModel(KeyID);
        Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment();
        if (orderM.PayState == (int)Enums.PayState.已支付)
        {
            //支付已成功
            JScript.AlertMsgOne(this, "支付已成功!", JScript.IconOption.笑脸);
            return;
        }
        else
        {
            //支付未成功
            string strWhere5 = string.Empty;
            if (KeyID > 0)
            {
                strWhere5 += " OrderID = " + KeyID;
            }
            strWhere5 += " and isnull(dr,0)=0";
            List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", strWhere5, "");
            if (prepayL.Count > 0 && orderM.AuditAmount == prepayL[0].price * -1)
            {
                //只用企业钱包支付,但是修改状态时出错
                SqlConnection con = new SqlConnection(LocalSqlServer);
                con.Open();
                SqlTransaction sqlTrans = con.BeginTransaction();
                int            order    = 0;
                int            prepay   = 0;
                try
                {
                    order  = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, KeyID, prepayL[0].price * -1, sqlTrans);
                    prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayL[0].ID, sqlTrans);
                    sqlTrans.Commit();
                }
                catch
                {
                    order  = 0;
                    prepay = 0;
                    sqlTrans.Rollback();
                }
                finally
                {
                    con.Close();
                }
                if (order > 0 && prepay > 0)
                {
                    JScript.AlertMsgOne(this, "支付已成功!", JScript.IconOption.笑脸);
                    return;
                }
                else
                {
                    JScript.AlertMsgOne(this, "支付处理中!", JScript.IconOption.哭脸);
                    return;
                }
            }

            string strWhere = string.Empty;
            if (KeyID > 0)
            {
                strWhere += " OrderID = " + KeyID;
            }
            strWhere += " and vdef3 = '1' and verifystatus = '40' and status = '20' and isnull(dr,0)=0";
            List <Hi.Model.PAY_Payment> payL = new Hi.BLL.PAY_Payment().GetList("", strWhere, "");
            if (payL.Count > 0)
            {
                //使用快捷支付成功,但是修改状态失败
                if (orderM.AuditAmount > payL[0].PayPrice)
                {
                    //是否使用企业钱包
                    string strWhere1 = string.Empty;
                    if (KeyID != 0)
                    {
                        strWhere1 += " OrderID = " + KeyID;
                    }
                    strWhere += " and isnull(dr,0)=0";
                    prepayM   = new Hi.BLL.PAY_PrePayment().GetList("", strWhere1, "")[0];
                }
                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, orderM.ID, payL[0].PayPrice + (prepayM.price * -1), sqlTrans);

                    if (orderM.AuditAmount == payL[0].PayPrice)
                    {
                        prepay = 1;
                        pay    = new Hi.BLL.PAY_Payment().updatePayState(con, payL[0].ID, sqlTrans);
                    }
                    else if (orderM.AuditAmount > payL[0].PayPrice)
                    {
                        prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans);
                        pay    = new Hi.BLL.PAY_Payment().updatePayState(con, payL[0].ID, sqlTrans);
                    }
                    else
                    {
                        order  = 0;
                        prepay = 0;
                        pay    = 0;
                        sqlTrans.Rollback();
                    }

                    sqlTrans.Commit();
                }
                catch
                {
                    order  = 0;
                    prepay = 0;
                    pay    = 0;
                    sqlTrans.Rollback();
                }
                finally
                {
                    con.Close();
                }
                if (order > 0 && prepay > 0 && pay > 0)
                {
                    JScript.AlertMsgOne(this, "支付成功!", JScript.IconOption.笑脸);
                    //Bind();
                    Response.Redirect("neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
                    return;
                }
                else
                {
                    JScript.AlertMsgOne(this, "支付处理中!", JScript.IconOption.哭脸);
                    return;
                }
            }
            else
            {
                //使用快捷支付未成功
                string strWhere2 = string.Empty;
                if (KeyID > 0)
                {
                    strWhere2 += " OrderID = " + KeyID;
                }
                strWhere2 += " and vdef3 = '1' and verifystatus = '40' and status = '10' and isnull(dr,0)=0";
                List <Hi.Model.PAY_Payment> payList = new Hi.BLL.PAY_Payment().GetList("", strWhere2, "ID desc");

                if (payList.Count > 0)
                {
                    //使用快捷支付,处理中
                    int regid = 0;
                    try
                    {
                        Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog();
                        regModel.OrderId    = KeyID;
                        regModel.Ordercode  = orderM.ReceiptNo;
                        regModel.number     = payList[0].guid;
                        regModel.Price      = payList[0].PayPrice;
                        regModel.Payuse     = "订单支付查询";
                        regModel.PayName    = new Hi.BLL.BD_Distributor().GetModel(orderM.DisID).DisName;
                        regModel.DisID      = orderM.DisID;
                        regModel.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                        regModel.Remark     = orderM.Remark;
                        regModel.DisName    = new Hi.BLL.BD_Company().GetModel(orderM.CompID).CompName;
                        regModel.CreateUser = this.UserID;
                        regModel.CreateDate = DateTime.Now;
                        regModel.LogType    = 1372;
                        regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    if (regid > 0)
                    {
                        if (orderM.AuditAmount > payList[0].PayPrice)
                        {
                            //是否使用企业钱包
                            string strWhere3 = string.Empty;
                            if (KeyID != 0)
                            {
                                strWhere3 += " OrderID = " + KeyID;
                            }
                            strWhere3 += " and isnull(dr,0)=0";
                            prepayM    = new Hi.BLL.PAY_PrePayment().GetList("", strWhere3, "")[0];
                        }

                        //调用快捷支付查询接口
                        string configPath = WebConfigurationManager.AppSettings["payment.config.path"];
                        PaymentEnvironment.Initialize(configPath);

                        Tx1372Request tx1372Request = new Tx1372Request();
                        tx1372Request.setInstitutionID("001520");
                        tx1372Request.setPaymentNo(payList[0].guid);
                        tx1372Request.process();

                        TxMessenger txMessenger = new TxMessenger();
                        String[]    respMsg     = txMessenger.send(tx1372Request.getRequestMessage(), tx1372Request.getRequestSignature());

                        Tx1372Response tx1372Response = new Tx1372Response(respMsg[0], respMsg[1]);

                        try
                        {
                            Hi.Model.PAY_RegisterLog regModel = new Hi.BLL.PAY_RegisterLog().GetModel(regid);
                            regModel.Start         = tx1372Response.getCode();
                            regModel.ResultMessage = tx1372Response.getMessage();
                            new Hi.BLL.PAY_RegisterLog().Update(regModel);
                            Hi.Model.PAY_Payment payM = new Hi.BLL.PAY_Payment().GetModel(payList[0].ID);
                            payM.status = tx1372Response.getStatus();
                            new Hi.BLL.PAY_Payment().Update(payM);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        if ("2000".Equals(tx1372Response.getCode()))
                        {
                            int Status = tx1372Response.getStatus();
                            if (Status == 10)
                            {
                                JScript.AlertMsgOne(this, "支付处理中!", JScript.IconOption.哭脸);
                                return;
                            }
                            else if (Status == 20)
                            {
                                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, KeyID, payList[0].PayPrice + prepayM.price * -1, sqlTrans);

                                    if (orderM.AuditAmount == payList[0].PayPrice)
                                    {
                                        prepay = 1;
                                        pay    = 1;
                                    }
                                    else if (orderM.AuditAmount > payList[0].PayPrice)
                                    {
                                        prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans);
                                        pay    = new Hi.BLL.PAY_Payment().updatePayState(con, payList[0].ID, sqlTrans);
                                    }
                                    else
                                    {
                                        sqlTrans.Rollback();
                                    }

                                    sqlTrans.Commit();
                                }
                                catch (Exception ex)
                                {
                                    order  = 0;
                                    prepay = 0;
                                    pay    = 0;
                                    sqlTrans.Rollback();
                                }
                                finally
                                {
                                    con.Close();
                                }

                                if (order > 0 && prepay > 0 && pay > 0)
                                {
                                    JScript.AlertMsgOne(this, "支付成功!", JScript.IconOption.笑脸);
                                    //Bind();
                                    Response.Redirect("neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
                                    return;
                                }
                                else
                                {
                                    JScript.AlertMsgOne(this, "系统繁忙,请稍后!", JScript.IconOption.错误);
                                    return;
                                }
                            }
                            else if (Status == 30)
                            {
                                bool f = false;
                                try
                                {
                                    Hi.Model.PAY_PrePayment prepayModel = new Hi.BLL.PAY_PrePayment().GetModel(prepayL[0].ID);
                                    prepayModel.Start = Convert.ToInt32(Enums.PrePayMentState.失败);
                                    f = new Hi.BLL.PAY_PrePayment().Update(prepayModel);
                                    Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(KeyID);
                                    orderModel.PayState = Convert.ToInt32(Enums.PayState.未支付);
                                    f = new Hi.BLL.DIS_Order().Update(orderModel);
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                                if (f)
                                {
                                    JScript.AlertMsgOne(this, "支付失败!", JScript.IconOption.错误);
                                    Bind();
                                    return;
                                }
                                else
                                {
                                    JScript.AlertMsgOne(this, "系统繁忙,请稍后!", JScript.IconOption.错误);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// 审核通过
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Hi.Model.DIS_OrderReturn OrderReturnModel = OrderReturnBll.GetModel(KeyID);

        string AuditUserID = string.Empty;
        string AuditDate   = string.Empty;
        string AuditRemark = string.Empty;
        int    pay         = 0;

        if (!string.IsNullOrEmpty(this.hidAuditUserID.Value))
        {
            AuditUserID = this.hidAuditUserID.Value.Trim().ToString();
        }
        //if (!string.IsNullOrEmpty(this.txtArriveDate.Value.Trim().ToString()))
        //{
        //    AuditDate = this.txtArriveDate.Value.Trim().ToString();
        //}
        if (!string.IsNullOrEmpty(this.lblArriveDate.InnerText.Trim().ToString()))
        {
            AuditDate = this.lblArriveDate.InnerText.Trim().ToString();
        }
        if (!string.IsNullOrEmpty(this.txtRemark.Value.Trim().ToString()))
        {
            AuditRemark = this.txtRemark.Value.Trim().ToString();
        }

        if (OrderReturnModel != null)
        {
            //判断退货单状态是否正确
            if (OrderReturnModel.ReturnState == (int)Enums.AuditState.提交)
            {
                Hi.Model.DIS_Order OrderModel = new Hi.BLL.DIS_Order().GetModel(OrderReturnModel.OrderID);

                if (OrderModel == null)
                {
                    JScript.AlertMsgOne(this, "订单信息有误!不能通过审核", JScript.IconOption.错误, 2500);
                    return;
                }
                int    State       = 0;
                string StateRemark = string.Empty;
                string LogRemark   = string.Empty;

                StateRemark = "退货审核通过";

                //订单支付状态
                pay       = OrderModel.PayState;
                LogRemark = "退货退款:" + OrderModel.PayedAmount.ToString("N");

                //判断订单状态是否正确
                if ((OrderModel.OState == (int)Enums.OrderState.已发货 || OrderModel.OState == (int)Enums.OrderState.已到货) && OrderModel.ReturnState == (int)Enums.ReturnState.申请退货)
                {
                    if (OrderModel.PayState == (int)Enums.PayState.已支付 || pay == (int)Enums.PayState.部分支付)
                    {
                        //订单已支付退货退款
                        //State = (int)Enums.AuditState.已审;
                        State                  = (int)Enums.AuditState.已完结;
                        OrderModel.OState      = (int)Enums.OrderState.已退货;
                        OrderModel.PayState    = (int)Enums.PayState.已退款;
                        OrderModel.ReturnState = (int)Enums.ReturnState.退货退款;
                    }
                    else
                    {
                        //订单未支付退货
                        OrderModel.OState = (int)Enums.OrderState.已退货;
                        State             = (int)Enums.AuditState.已完结;
                    }

                    #region
                    //if (OrderModel.Otype == (int)Enums.OType.赊销订单)
                    //{
                    //if (OrderModel.PayState == (int)Enums.PayState.已支付 || pay == (int)Enums.PayState.部分支付 || OrderModel.PayState == (int)Enums.PayState.已结算)
                    //{
                    //    //订单已支付退货退款
                    //    //State = (int)Enums.AuditState.已审;
                    //    State = (int)Enums.AuditState.已完结;
                    //    OrderModel.OState = (int)Enums.OrderState.已退货;
                    //    OrderModel.PayState = (int)Enums.PayState.已退款;
                    //    OrderModel.ReturnState = (int)Enums.ReturnState.退货退款;
                    //}
                    //else
                    //{
                    //    //订单未支付退货
                    //    OrderModel.OState = (int)Enums.OrderState.已退货;
                    //    State = (int)Enums.AuditState.已审;
                    //}
                    //}
                    //else
                    //{
                    //    //OrderModel.OState = (int)Enums.OrderState.退货处理;
                    //    //State = (int)Enums.AuditState.已审;
                    //    if (OrderModel.PayState == (int)Enums.PayState.已支付 || pay == (int)Enums.PayState.部分支付 || OrderModel.PayState == (int)Enums.PayState.已结算)
                    //    {
                    //        OrderModel.OState = (int)Enums.OrderState.已退货;
                    //        OrderModel.PayState = (int)Enums.PayState.已退款;
                    //        OrderModel.ReturnState = (int)Enums.ReturnState.退货退款;

                    //        State = (int)Enums.AuditState.已完结;
                    //    }
                    //    else
                    //    {
                    //        OrderModel.OState = (int)Enums.OrderState.已退货;
                    //        State = (int)Enums.AuditState.已审;
                    //    }
                    //}
                    #endregion
                    OrderModel.ts         = DateTime.Now;
                    OrderModel.modifyuser = this.UserID;

                    OrderReturnModel.AuditUserID = AuditUserID.ToInt(0);
                    OrderReturnModel.AuditDate   = AuditDate.ToDateTime();
                    OrderReturnModel.AuditRemark = AuditRemark;
                    OrderReturnModel.ReturnState = State;
                    OrderReturnModel.ts          = DateTime.Now;
                    OrderReturnModel.modifyuser  = this.UserID;


                    #region   把退款金额变为代理商的企业钱包金额
                    int           order  = 0;
                    int           prepay = 0;
                    SqlConnection con    = new SqlConnection(LocalSqlServer);
                    con.Open();
                    SqlTransaction sqlTrans = con.BeginTransaction();

                    Hi.Model.PAY_PrePayment PrepayModel = new Hi.Model.PAY_PrePayment();
                    Hi.BLL.PAY_PrePayment   PrepayBLL   = new Hi.BLL.PAY_PrePayment();
                    PrepayModel.CompID    = OrderModel.CompID;
                    PrepayModel.DisID     = OrderModel.DisID;
                    PrepayModel.OrderID   = OrderModel.ID;
                    PrepayModel.Start     = 1;
                    PrepayModel.PreType   = 4;
                    PrepayModel.price     = OrderModel.PayedAmount; //已支付金额
                    PrepayModel.Paytime   = DateTime.Now;
                    PrepayModel.CrateUser = this.UserID;
                    PrepayModel.CreatDate = DateTime.Now;
                    PrepayModel.OldId     = 0;

                    PrepayModel.AuditState = 2;
                    PrepayModel.IsEnabled  = 1;
                    PrepayModel.AuditUser  = this.UserID;
                    PrepayModel.dr         = 0;
                    PrepayModel.ts         = DateTime.Now;
                    PrepayModel.guid       = Common.Number_repeat("");

                    try
                    {
                        //order = new Hi.BLL.DIS_Order().UpdateOrderByggh(con, OrderModel, sqlTrans, KeyID, (int)Enums.AuditState.已完结);
                        order = OrderInfoType.ReturnOrderUpdate(con, sqlTrans, OrderReturnModel, OrderModel);

                        //if (OrderModel.Otype == (int)Enums.OType.赊销订单)
                        //{
                        //    //支付的订单 生成企业钱包
                        //    if (pay == (int)Enums.PayState.已支付||pay == (int)Enums.PayState.部分支付|| pay == (int)Enums.PayState.已结算)
                        //    {
                        //        prepay = new Hi.BLL.PAY_PrePayment().InsertPrepay(con, PrepayModel, sqlTrans);
                        //    }
                        //    else
                        //    {
                        //        //未支付的订单 不生成企业钱包
                        //        prepay = 1;
                        //    }
                        //}
                        //else
                        //{
                        if (pay == (int)Enums.PayState.已支付 || pay == (int)Enums.PayState.部分支付)
                        {
                            //支付的订单 生成企业钱包
                            prepay = new Hi.BLL.PAY_PrePayment().InsertPrepay(con, PrepayModel, sqlTrans);

                            //退款减积分
                            OrderInfoType.AddIntegral(CompID, OrderModel.DisID, "1", 2, OrderModel.ID, OrderModel.PayedAmount, "订单退款", "", this.UserID);
                        }
                        else
                        {
                            //未支付的订单 不生成企业钱包
                            prepay = 1;
                        }
                        //}

                        sqlTrans.Commit();
                    }
                    catch
                    {
                        order  = 0;
                        prepay = 0;
                        sqlTrans.Rollback();
                    }
                    finally
                    {
                        con.Close();
                    }
                    #endregion

                    if (prepay > 0 && order > 0)
                    {
                        if (OrderInfoType.rdoOrderAudit("订单下单数量是否取整", this.CompID) == "0")
                        {
                            //退货审核通过,返还商品库存
                            string sql = new Hi.BLL.DIS_Order().GetSqlAddInve(OrderModel.ID, null, 0);
                            new Hi.BLL.DIS_Order().UpdateOrderState(sql);
                        }

                        if (pay == (int)Enums.PayState.未支付)
                        {
                            // type : "4":订单发货通知;"3":订单状态变更通知(待发货、审批通过);"2":订单支付通知;"1":下单通知
                            new Common().GetWxService("44", OrderReturnModel.OrderID.ToString(), "0");

                            //代理商手机号
                            string Phone = Common.GetDis(OrderModel.DisID, "Phone");
                            string msg   = "您的订单:" + OrderModel.ReceiptNo + "退货申请已通过!";
                            //退款向代理商推送信息提示
                            Common.GetPhone(Phone, msg);
                        }
                        else
                        {
                            //type : "4":订单发货通知;"3":订单状态变更通知(待发货、审批通过);"2":订单支付通知;"1":下单通知
                            new Common().GetWxService("44", OrderReturnModel.OrderID.ToString(), "0");
                            new Common().GetWxService("45", OrderReturnModel.OrderID.ToString(), "0");

                            //代理商手机号
                            string Phone = Common.GetDis(OrderModel.DisID, "Phone");
                            string msg   = "您的订单:" + OrderModel.ReceiptNo + "退货金额已退回您的企业钱包账户,请查收!";
                            //退款向代理商推送信息提示
                            Common.GetPhone(Phone, msg);
                        }

                        Utils.AddSysBusinessLog(this.CompID, "Order", OrderReturnModel.OrderID.ToString(), StateRemark, LogRemark);

                        Response.Write("<script language=\"javascript\">window.parent.AuditReturn('" + Common.DesEncrypt(this.KeyID.ToString(), Common.EncryptKey) + "');</script>");
                    }
                }
                else
                {
                    JScript.AlertMsgOne(this, "订单信息有误!不能通过审核!", JScript.IconOption.错误, 2500);
                    return;
                }
            }
            else
            {
                JScript.AlertMsgOne(this, "数据状态不正确,不能进行审核!", JScript.IconOption.错误, 2500);
            }
        }
        else
        {
            JScript.AlertMsgOne(this, "数据不存在!", JScript.IconOption.错误, 2500);
        }
    }