예제 #1
0
    public void bind_date(int _id)
    {
        Cms.BLL.C_order   bll   = new Cms.BLL.C_order();
        Cms.Model.C_order model = bll.GetModel(_id);
        ordernum.InnerHtml         = model.order_num;
        updateTime.InnerHtml       = model.updateTime.ToString();
        OrderStatus.InnerHtml      = model.order_status.ToString() == "0" ? "未完单" : "已完单";
        isPayment.InnerHtml        = model.is_payment.ToString() == "0" ? "未支付" : "已支付";
        countprice.InnerHtml       = Convert.ToDecimal(model.price_sum).ToString("0.00");
        Quantity.InnerHtml         = model.quantity_sum.ToString();
        isDelivery.InnerHtml       = model.is_delivery.ToString() == "0" ? "未发货" : "已发货";
        is_receiving.InnerHtml     = model.is_receiving.ToString() == "0" ? "未收货" : "已收货";
        integral_sum.InnerHtml     = model.integral_sum.ToString();
        pay_method.InnerHtml       = model.pay_method.ToString() == "" ? "微信支付" : model.pay_method.ToString();
        shipping_method.InnerHtml  = model.shipping_method.ToString();
        note.InnerHtml             = model.note.ToString();
        recommended_code.InnerHtml = model.recommended_code.ToString();
        courierNumber.Text         = model.courier_number.ToString();
        fahuoCode.Text             = model.fahuoCode.ToString();
        fahuoMsg.Text = model.fahuoMsg.ToString();
        if (model.is_delivery == 1)
        {
            btnSubmit.Visible = false;
        }
        #region 会员信息=====================
        int            struserid = Convert.ToInt32(model.user_id);
        Cms.BLL.C_user blluser   = new Cms.BLL.C_user();
        DataSet        ds2       = blluser.GetList("id=" + struserid);
        if (ds2 != null && ds2.Tables[0].Rows.Count > 0)
        {
            UserName.InnerHtml = ds2.Tables[0].Rows[0]["username"].ToString();
            //userMoney.InnerHtml =Convert.ToDecimal(ds2.Tables[0].Rows[0]["userMoney"]).ToString("0.00");
            //userJifen.InnerHtml = ds2.Tables[0].Rows[0]["userscore"].ToString();
        }
        else
        {
            userinfo.InnerHtml = "匿名用户";
        }
        #endregion

        #region 产品信息===========================
        Cms.BLL.C_ordersub bllordersub = new Cms.BLL.C_ordersub();
        DataSet            ds1         = bllordersub.GetList("order_id=" + _id);
        if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
        {
            Repeaterordersub.DataSource = ds1.Tables[0].DefaultView;
            Repeaterordersub.DataBind();
        }
        #endregion

        #region 收货信息===========================

        DataSet ds3 = new Cms.BLL.c_user_address().GetList("id=" + model.adress_id);
        if (ds3 != null && ds3.Tables[0].Rows.Count > 0)
        {
            RepAddress.DataSource = ds3.Tables[0].DefaultView;
            RepAddress.DataBind();
        }
        #endregion
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        openid = MyCommFun.RequestOpenid();
        int otid = Convert.ToInt32(Request["orderid"].ToString());

        expireMinute = MyCommFun.RequestInt("expireminute");
        if (expireMinute == 0)
        {
            expireMinute = 30;
        }
        else if (expireMinute == -1)
        {  //如果为-1,则有限期间为1年
            expireMinute = 60 * 12 * 365;
        }
        //if (openid == "" || otid == 0 || wid == 0)
        //{
        //    return;
        //}
        Cms.BLL.C_order   otBll       = new Cms.BLL.C_order();
        Cms.Model.C_order orderEntity = otBll.GetModel(otid);
        order_num.Text = orderEntity.order_num;
        litMoney.Text  = Convert.ToDecimal(orderEntity.price_sum).ToString("0.00");
        litDate.Text   = orderEntity.updateTime.ToString();
        WxPayData(Convert.ToDecimal(orderEntity.price_sum), orderEntity.id.ToString(), orderEntity.order_num);

        FileHelper.Write(HttpRuntime.AppDomainAppPath + "\\log.txt", packageValue);
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Log.Info(this.GetType().ToString(), "page load");
        if (!IsPostBack)
        {
            Cms.Model.C_user userModel    = adminUser.GetuserLoginState();
            int               otid        = Convert.ToInt32(Request["orderid"].ToString());
            Cms.BLL.C_order   otBll       = new Cms.BLL.C_order();
            Cms.Model.C_order orderEntity = otBll.GetModel(otid);
            order_num.Text = orderEntity.order_num;
            litMoney.Text  = Convert.ToDecimal(orderEntity.price_sum).ToString("0.00");
            litDate.Text   = orderEntity.updateTime.ToString();
            string openid    = userModel.openid.ToString();
            string total_fee = ((int)(Convert.ToDecimal(orderEntity.price_sum) * 100)).ToString();
            //检测是否给当前页面传递了相关参数
            if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(total_fee))
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>");
                Log.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit...");
                submit.Visible = false;
                return;
            }

            //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
            JsApiPay jsApiPay = new JsApiPay(this);
            jsApiPay.openid  = openid;
            jsApiPay.orderid = orderEntity.order_num;
            DataTable dt = new Cms.BLL.C_ordersub().GetList("order_id=" + orderEntity.id).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                jsApiPay.productName = dt.Rows[0]["title"].ToString();
            }
            else
            {
                jsApiPay.productName = "泓源鼎盛酒业商品";
            }
            try
            {
                jsApiPay.total_fee = int.Parse(total_fee);


                //JSAPI支付预处理

                WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult();

                wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
                orderNum     = Request["orderid"].ToString();
                Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                //在页面上显示订单信息
                //Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>");
                //Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>");
            }
            catch (Exception ex)
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>" + ex.Message.ToString() + Convert.ToDecimal(orderEntity.price_sum).ToString());
                submit.Visible = false;
            }
        }
    }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         otid = MyCommFun.RequestInt("otid");
         if (otid == 0)
         {
             return;
         }
         Cms.BLL.C_order otBll = new Cms.BLL.C_order();
         ordertmp = otBll.GetModel(otid);
     }
 }
예제 #5
0
    protected void btnSubmit_Click_Fahuo(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(this.Request.QueryString["orderid"] ?? "0");//ID

        Cms.BLL.C_order   bll   = new Cms.BLL.C_order();
        Cms.Model.C_order model = bll.GetModel(id);
        model.courier_number = courierNumber.Text.ToString();
        model.fahuoCode      = fahuoCode.Text.ToString();
        model.fahuoMsg       = fahuoMsg.Text.ToString();
        model.is_delivery    = 1;
        if (bll.Update(model))
        {
            JscriptMsg("发货成功!", "orderlist.aspx", "Success");
        }
        else
        {
            JscriptMsg("发货失败!", "orderlist.aspx", "Error");
        }
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            openid = MyCommFun.RequestOpenid();
            otid   = MyCommFun.RequestInt("otid");
            int wid = MyCommFun.RequestWid();
            if (openid == "" || otid == 0 || wid == 0)
            {
                return;
            }

            //WeiXinCRMComm wxComm = new WeiXinCRMComm();
            //string err = "";
            //token = wxComm.getAccessToken(wid, out err);

            Cms.BLL.C_order otBll = new Cms.BLL.C_order();
            ordertmp = otBll.GetModel(otid);
        }
    }
예제 #7
0
    /// <summary>
    /// 【微支付】 订单付款成功,处理订单:1将订单的状态改成付款完成;
    ///
    /// </summary>
    /// <param name="beforeFunName"></param>
    /// <param name="notify_id">通知id</param>
    /// <param name="out_trade_no">商户订单号</param>
    /// <param name="transaction_id">订单交易号</param>
    /// <param name="pay_info">支付结果</param>
    /// <param name="total_fee">付款金额(单位为分)</param>
    /// <param name="otid">订单临时表id</param>
    /// <returns>有错误则返回错误信息,正确,则返回空字符串</returns>
    public string ProcessPaySuccess_wx(string beforeFunName, string notify_id, string out_trade_no, string transaction_id, string pay_info, int total_fee, int otid, int wid)
    {
        string payTmpType = "【微支付】";

        total_fee = total_fee / 100;
        Cms.BLL.C_order orderBll = new Cms.BLL.C_order();

        string funName = payTmpType + beforeFunName + " ProcessPaySuccess_wx ";

        Cms.BLL.wx_log   logBll   = new Cms.BLL.wx_log();
        Cms.Model.wx_log logModel = new Cms.Model.wx_log();
        logModel.modelName   = "微支付";
        logModel.funName     = funName;
        logModel.logsContent = "开始执行ProcessPaySuccess_wx方法[otid:" + otid + "]";
        logBll.Add(logModel);
        try
        {
            #region 数据同步前
            IList <Cms.Model.C_order> orderlist = orderBll.GetModelList("id=" + otid + " and order_num='" + out_trade_no + "'");
            if (orderlist == null || orderlist.Count <= 0)
            {
                logModel.modelName   = payTmpType;
                logModel.funName     = funName;
                logModel.logsContent = "订单号【" + out_trade_no + "】订单号不存在";
                logModel.logsType    = 0;
                logBll.Add(logModel);
                return("订单号不存在");
            }
            ////这个暂时不处理
            //if (logBll.ExistsFlg((out_trade_no + otid)))
            //{  //如果已经处理过,则不再处理
            //    return "";
            //}
            //logBll.AddFlg(wid, payTmpType, funName, (out_trade_no + otid));//加标志,防止重复提交

            Cms.Model.C_order orderEntity = orderlist[0];
            //if (orderEntity.price_sum > total_fee)
            //{
            //    return "付款的金额(" + total_fee + ")小于订单的预付款金额(" + orderEntity.price_sum + ")信息,直接退款";
            //}
            orderEntity.notify_id = notify_id;
            orderEntity.trade_no  = transaction_id;
            orderEntity.pay_info  = pay_info;
            //orderEntity.price_sum = total_fee;
            orderEntity.payment_time   = DateTime.Now;
            orderEntity.is_transaction = 0;
            orderEntity.order_status   = 0;
            orderEntity.is_payment     = 1;


            #region 修改积分============================
            Cms.BLL.C_user   user_bll   = new Cms.BLL.C_user();
            Cms.Model.C_user user_model = new Cms.BLL.C_user().GetModel(Convert.ToInt32(orderEntity.user_id));
            user_model.userallscore = user_model.userallscore + orderEntity.integral_sum;
            user_model.userscore    = user_model.userscore + orderEntity.integral_sum;
            user_bll.Update(user_model);

            Cms.BLL.C_integral_rec   integral_BLL   = new Cms.BLL.C_integral_rec();
            Cms.Model.C_integral_rec integral_model = new Cms.Model.C_integral_rec();

            DataTable dt = new Cms.BLL.C_ordersub().GetList("order_id=" + otid).Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                integral_model.article_id = Convert.ToInt32(dt.Rows[i]["article_id"].ToString());
                integral_model.user_id    = Convert.ToInt32(dt.Rows[i]["user_id"].ToString());
                integral_model.usercard   = user_model.usercard;
                integral_model.openid     = user_model.openid;
                integral_model.numberid   = dt.Rows[i]["id"].ToString();
                integral_model.scorename  = "购买产品";
                integral_model.title      = dt.Rows[i]["title"].ToString();
                integral_model.wescore    = Convert.ToInt32(dt.Rows[i]["integral"].ToString() == "" ? "0" : dt.Rows[i]["integral"].ToString()) * Convert.ToInt32(dt.Rows[i]["quantity"].ToString());
                integral_model.quantity   = Convert.ToInt32(dt.Rows[i]["quantity"].ToString());
                integral_model.type       = 0;
                integral_model.updateTime = DateTime.Now;
                integral_BLL.Add(integral_model);
                try
                {
                    wxuser.UserSale wu = new wxuser.UserSale();
                    wu = wxuser.getUserScore(user_model.usercard, user_model.openid, dt.Rows[i]["id"].ToString(), "购买产品", "+" + integral_model.wescore);
                }
                catch (Exception ex)
                {
                }
            }

            #endregion
            ////判断是否需要立即发货
            //if (orderEntity.express_status == 0)
            //{
            //    //立即发货
            //    FaHuoProc fahuo = new FaHuoProc();

            //    BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay();
            //    Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid);
            //    Dictionary<string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, orderEntity);
            //    string errcode = fahuoDict["errcode"].ToString();
            //    string errmsg = fahuoDict["errmsg"].ToString();
            //    orderEntity.fahuoCode = errcode;
            //    orderEntity.fahuoMsg = errmsg;
            //    if (errcode == "0")
            //    {
            //        orderEntity.express_status = 2;
            //        orderEntity.express_time = DateTime.Now;
            //    }
            //    else
            //    {
            //        orderEntity.express_status = 1;
            //    }
            //}

            bool ret = orderBll.Update(orderEntity);
            if (!ret)
            {
                logModel.modelName   = payTmpType;
                logModel.funName     = funName;
                logModel.logsContent = "订单号【" + out_trade_no + "】支付成功后处理数据失败";
                logModel.logsType    = 0;
                logBll.Add(logModel);

                return("订单号【" + out_trade_no + "】支付成功后处理数据失败");
            }
            logModel.modelName   = payTmpType;
            logModel.funName     = funName;
            logModel.logsContent = "订单号【" + out_trade_no + "】支付成功后,处理数据成功";
            logModel.logsType    = 1;
            logBll.Add(logModel);

            return("");

            #endregion
        }
        catch (Exception ex)
        {
            logModel.modelName   = payTmpType;
            logModel.funName     = funName;
            logModel.logsContent = "订单号【" + out_trade_no + "】支付成功后处理数据同步出现错误:" + ex.Message;
            logModel.logsType    = 0;
            logBll.Add(logModel);

            return(null);
        }
    }
예제 #8
0
    public override void ProcessNotify()
    {
        WxPayData notifyData = GetNotifyData();

        setlog("transaction_id", notifyData.GetValue("transaction_id").ToString());
        //检查支付结果中transaction_id是否存在
        if (!notifyData.IsSet("transaction_id"))
        {
            setlog("transaction_id", "不存在");
            //若transaction_id不存在,则立即返回结果给微信支付后台
            WxPayData res = new WxPayData();
            res.SetValue("return_code", "FAIL");
            res.SetValue("return_msg", "支付结果中微信订单号不存在");
            Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
            page.Response.Write(res.ToXml());
            page.Response.End();
        }
        else
        {
            #region 支付成功后处理订单信息=============================================================
            setlog("transaction_id", "存在");
            Cms.BLL.C_order otBll = new Cms.BLL.C_order();

            setlog("orderid", notifyData.GetValue("out_trade_no").ToString());
            DataTable DT = otBll.GetList("order_num='" + notifyData.GetValue("out_trade_no").ToString() + "'").Tables[0];
            if (DT != null && DT.Rows.Count > 0)//购物
            {
                int orderId = Convert.ToInt32(DT.Rows[0]["id"].ToString());
                Cms.Model.C_order ordertmp = otBll.GetModel(orderId);
                ordertmp.trade_no = notifyData.GetValue("transaction_id").ToString();
                //ordertmp.notify_id = notifyData.GetValue("notify_id").ToString();
                //ordertmp.pay_info = notifyData.GetValue("pay_info").ToString();
                //orderEntity.price_sum = total_fee;
                ordertmp.payment_time   = DateTime.Now;
                ordertmp.is_transaction = 0;
                ordertmp.order_status   = 0;
                ordertmp.is_payment     = 1;
                #region 修改积分============================
                //setlog("修改积分", notifyData.GetValue("out_trade_no").ToString());
                //Cms.BLL.C_user user_bll = new Cms.BLL.C_user();
                //Cms.Model.C_user user_model = new Cms.BLL.C_user().GetModel(Convert.ToInt32(ordertmp.user_id));
                //user_model.userallscore = user_model.userallscore + ordertmp.integral_sum;
                //user_model.userscore = user_model.userscore + ordertmp.integral_sum;
                //user_bll.Update(user_model);

                //Cms.BLL.C_integral_rec integral_BLL = new Cms.BLL.C_integral_rec();
                //Cms.Model.C_integral_rec integral_model = new Cms.Model.C_integral_rec();
                //DataTable dt = new Cms.BLL.C_ordersub().GetList("order_id=" + ordertmp.id).Tables[0];
                //if (dt != null && dt.Rows.Count > 0)
                //{
                //    for (int i = 0; i < dt.Rows.Count; i++)
                //    {
                //        integral_model.article_id = Convert.ToInt32(dt.Rows[i]["article_id"].ToString());
                //        integral_model.user_id = Convert.ToInt32(dt.Rows[i]["user_id"].ToString());
                //        integral_model.usercard = user_model.usercard;
                //        integral_model.openid = user_model.openid;
                //        integral_model.numberid = dt.Rows[i]["id"].ToString();
                //        integral_model.scorename = "购买产品";
                //        integral_model.title = dt.Rows[i]["title"].ToString();
                //        integral_model.wescore = Convert.ToInt32(dt.Rows[i]["integral"].ToString() == "" ? "0" : dt.Rows[i]["integral"].ToString()) * Convert.ToInt32(dt.Rows[i]["quantity"].ToString());
                //        integral_model.quantity = Convert.ToInt32(dt.Rows[i]["quantity"].ToString());
                //        integral_model.type = 0;
                //        integral_model.updateTime = DateTime.Now;
                //        integral_BLL.Add(integral_model);
                //        try
                //        {
                //            wxuser.UserSale wu = new wxuser.UserSale();//积分修改同步到ERP
                //            wu = wxuser.getUserScore(user_model.usercard, user_model.openid, dt.Rows[i]["id"].ToString(), "购买产品", "+" + integral_model.wescore);
                //        }
                //        catch (Exception ex)
                //        {
                //            page.Response.Write(ex.Message);
                //            page.Response.End();
                //        }
                //    }
                //}
                #endregion
                #region 减库存加销量============================



                DataTable dt = new Cms.BLL.C_ordersub().GetList("order_id=" + ordertmp.id).Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        try
                        {
                            int productId = Convert.ToInt32(dt.Rows[i]["article_id"].ToString());
                            int quantity  = Convert.ToInt32(dt.Rows[i]["quantity"].ToString());
                            Cms.Model.C_product product = new Cms.BLL.C_product().GetModel(productId);
                            if (product.stock - quantity > 0)
                            {
                                product.stock = product.stock - quantity;
                                product.sales = product.sales + quantity;
                                new Cms.BLL.C_product().Update(product);
                            }
                        }
                        catch (Exception ex)
                        {
                            page.Response.Write(ex.Message);
                            page.Response.End();
                        }
                    }
                }
                #endregion
                Cms.BLL.wx_log   logBll     = new Cms.BLL.wx_log();
                Cms.Model.wx_log logModel   = new Cms.Model.wx_log();
                string           payTmpType = "【微支付】";
                string           funName    = payTmpType + "【微支付】 订单付款成功,处理订单" + " ProcessPaySuccess_wx ";
                bool             ret        = otBll.Update(ordertmp);//修改主表订单信息
                if (!ret)
                {
                    logModel.modelName   = payTmpType;
                    logModel.funName     = funName;
                    logModel.logsContent = "订单号【" + notifyData.GetValue("out_trade_no").ToString() + "】支付成功后处理数据失败";
                    logModel.logsType    = 0;
                    logBll.Add(logModel);
                }
                logModel.modelName   = payTmpType;
                logModel.funName     = funName;
                logModel.logsContent = "订单号【" + notifyData.GetValue("out_trade_no").ToString() + "】支付成功后,处理数据成功";
                logModel.logsType    = 1;
                logBll.Add(logModel);
            }
            else//充值
            {
                DataTable dtRecharge = new Cms.BLL.C_user_recharge().GetList("orderNumber='" + notifyData.GetValue("out_trade_no").ToString() + "'").Tables[0];
                if (dtRecharge != null && dtRecharge.Rows.Count > 0)
                {
                    int orderId = Convert.ToInt32(dtRecharge.Rows[0]["id"].ToString());
                    Cms.Model.C_user_recharge orderRecharge = new Cms.BLL.C_user_recharge().GetModel(orderId);
                    orderRecharge.isPay = 1;

                    Cms.Model.C_user user = new Cms.BLL.C_user().GetModel(Convert.ToInt32(orderRecharge.userId));
                    user.userMoney = user.userMoney + orderRecharge.price;
                    new Cms.BLL.C_user().Update(user);

                    Cms.BLL.wx_log   logBll     = new Cms.BLL.wx_log();
                    Cms.Model.wx_log logModel   = new Cms.Model.wx_log();
                    string           payTmpType = "【微支付】";
                    string           funName    = payTmpType + "【微支付】 订单付款成功,处理订单" + " ProcessPaySuccess_wx ";
                    bool             ret        = new Cms.BLL.C_user_recharge().Update(orderRecharge);//修改订单信息
                    if (!ret)
                    {
                        logModel.modelName   = payTmpType;
                        logModel.funName     = funName;
                        logModel.logsContent = "订单号【" + notifyData.GetValue("out_trade_no").ToString() + "】支付成功后处理数据失败";
                        logModel.logsType    = 0;
                        logBll.Add(logModel);
                    }
                    else
                    {
                        logModel.modelName   = payTmpType;
                        logModel.funName     = funName;
                        logModel.logsContent = "订单号【" + notifyData.GetValue("out_trade_no").ToString() + "】支付成功后,处理数据成功";
                        logModel.logsType    = 1;
                        logBll.Add(logModel);
                    }
                }
            }

            #endregion
        }

        string transaction_id = notifyData.GetValue("transaction_id").ToString();
        //查询订单,判断订单真实性
        if (!QueryOrder(transaction_id))
        {
            setlog("return_code", "FAIL");
            //若订单查询失败,则立即返回结果给微信支付后台
            WxPayData res = new WxPayData();
            res.SetValue("return_code", "FAIL");
            res.SetValue("return_msg", "订单查询失败");
            Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
            page.Response.Write(res.ToXml());
            page.Response.End();
        }
        //查询订单成功
        else
        {
            setlog("return_code", "SUCCESS");
            WxPayData res = new WxPayData();
            res.SetValue("return_code", "SUCCESS");
            res.SetValue("return_msg", "OK");
            Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
            page.Response.Write(res.ToXml());
            page.Response.End();
            setlog("SUCCESS", res.ToXml());
        }
    }
예제 #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //商户号
        string partner = "1220201501";


        //密钥
        string key = "19ace89a7acd6e14ac3c66b2852f14d6";

        //创建请求对象
        RequestHandler reqHandler = new RequestHandler(Context);

        //通信对象
        TenpayHttpClient httpClient = new TenpayHttpClient();

        //应答对象
        ClientResponseHandler resHandler = new ClientResponseHandler();

        int otid = Convert.ToInt32(Request["orderid"].ToString());

        Cms.BLL.C_order   otBll       = new Cms.BLL.C_order();
        Cms.Model.C_order orderEntity = otBll.GetModel(otid);

        //-----------------------------
        //设置请求参数
        //-----------------------------
        reqHandler.init();
        reqHandler.setKey(key);
        reqHandler.setGateUrl("https://mch.tenpay.com/refundapi/gateway/refund.xml");

        reqHandler.setParameter("partner", partner);
        //out_trade_no和transaction_id至少一个必填,同时存在时transaction_id优先
        //reqHandler.setParameter("out_trade_no", "1458268681");
        reqHandler.setParameter("transaction_id", orderEntity.trade_no);
        reqHandler.setParameter("out_refund_no", orderEntity.order_num);
        reqHandler.setParameter("total_fee", ((int)(orderEntity.price_sum * 100)).ToString());//((int)(orderEntity.price_sum * 100)).ToString()
        reqHandler.setParameter("refund_fee", ((int)(orderEntity.price_sum * 100)).ToString());
        //reqHandler.setParameter("refund_fee", "100");
        reqHandler.setParameter("op_user_id", "1220201501");
        reqHandler.setParameter("op_user_passwd", MD5Util.GetMD5("dbezhifu1866", "GBK"));
        reqHandler.setParameter("service_version", "1.1");

        string requestUrl = reqHandler.getRequestURL();

        httpClient.setCertInfo("d:\\wwwroot\\anpurui\\wwwroot\\1220201501_20150203112358.pfx", "1220201501");
        //设置请求内容
        httpClient.setReqContent(requestUrl);
        //设置超时
        httpClient.setTimeOut(10);

        string rescontent = "";


        //后台调用
        if (httpClient.call())
        {
            //获取结果
            rescontent = httpClient.getResContent();



            resHandler.setKey(key);
            //设置结果参数
            resHandler.setContent(rescontent);

            //判断签名及结果
            if (resHandler.isTenpaySign() && resHandler.getParameter("retcode") == "0")
            {
                //商户订单号
                string out_trade_no = resHandler.getParameter("out_trade_no");
                //财付通订单号
                string transaction_id = resHandler.getParameter("transaction_id");

                DataTable dt = otBll.GetList("trade_no='" + transaction_id + "'").Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    int id = Convert.ToInt32(dt.Rows[0]["id"]);
                    Cms.Model.C_order orderModel = otBll.GetModel(id);
                    orderModel.is_refund = 3;
                    if (otBll.Update(orderModel))
                    {
                        JscriptMsg("退款成功!", "/shop/myOrder.aspx", "Success");
                    }
                }

                //业务处理
                //Response.Write("退款成功!" + out_trade_no + transaction_id);
            }
            else
            {
                //错误时,返回结果未签名。
                //如包格式错误或未确认结果的,请使用原来订单号重新发起,确认结果,避免多次操作
                //Response.Write("业务错误信息或签名错误:" + resHandler.getParameter("retcode") + "," + resHandler.getParameter("retmsg") + "<br>");
                JscriptMsg("退款失败!", "/shop/myOrder.aspx", "Error");
            }
        }
        else
        {
            //后台调用通信失败
            //Response.Write("call err:" + httpClient.getErrInfo() + "<br>" + httpClient.getResponseCode() + "<br>");
            JscriptMsg("退款失败!", "/shop/myOrder.aspx", "Error");
            //有可能因为网络原因,请求已经处理,但未收到应答。
        }


        //获取debug信息,建议把请求、应答内容、debug信息,通信返回码写入日志,方便定位问题

        //Response.Write("http res:" + httpClient.getResponseCode() + "," + httpClient.getErrInfo() + "<br>");
        //Response.Write("req url:" + requestUrl + "<br/>");
        //Response.Write("req debug:" + reqHandler.getDebugInfo() + "<br/>");
        //Response.Write("res content:" + Server.HtmlEncode(rescontent) + "<br/>");
        //Response.Write("res debug:" + Server.HtmlEncode(resHandler.getDebugInfo()) + "<br/>");
    }
예제 #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Cms.Model.C_order model)
 {
     return(dal.Update(model));
 }
예제 #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Cms.Model.C_order model)
 {
     return(dal.Add(model));
 }