Esempio n. 1
0
    /// <summary>
    /// 异步回调后-->验证支付单状态-->如果正常,更新订单状态
    /// </summary>
    /// <param name="mod">订单模型</param>
    /// <param name="paylogMod">订单支付日志模型</param>
    public static void FinalStep(M_Payment pinfo, M_OrderList mod, M_Order_PayLog paylogMod)
    {
        B_OrderList    orderBll  = new B_OrderList();
        B_CartPro      cartBll   = new B_CartPro();
        B_Order_PayLog paylogBll = new B_Order_PayLog();
        B_User         buser     = new B_User();

        //订单已处理,避免重复(如已处理过,则继续处理下一张订单)
        if (mod.OrderStatus >= 99)
        {
            ZLLog.L(ZoomLa.Model.ZLEnum.Log.safe, new M_Log()
            {
                Action  = "支付回调异常,订单状态已为99",
                Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo
            });
            return;
        }
        //已经收到钱了,所以先执行
        orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + pinfo.MoneyTrue, mod.id);
        if (mod.Ordertype == (int)M_OrderList.OrderEnum.Domain)//域名订单
        {
            orderBll.UpOrderinfo("OrderStatus=1", mod.id);
            //Response.Redirect("~/Plugins/Domain/DomReg2.aspx?OrderNo=" + mod.OrderNo);
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.IDC)//IDC服务
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);
            cartBll.IDC_UpdateEndTimeByOid(mod.id);
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Purse)//余额充值,不支持银币
        {
            buser.ChangeVirtualMoney(mod.Userid, new M_UserExpHis()
            {
                score     = (int)mod.Ordersamount,
                ScoreType = (int)M_UserExpHis.SType.Purse,
                detail    = "余额充值,订单号:" + mod.OrderNo
            });
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);            //成功的订单
        }
        else if ((mod.Ordertype == (int)M_OrderList.OrderEnum.IDCRen)) //IDC服务续费
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);
            B_Product proBll = new B_Product();
            //更新旧订单的期限
            if (string.IsNullOrEmpty(mod.Ordermessage))//购物车ID
            {
                //function.WriteErrMsg("出错,无需续费订单信息,请联系管理员!!!");
                throw new Exception("出错,无续费订单信息,请联系管理员");
            }
            M_CartPro newCartMod = cartBll.SelModByOrderID(mod.id);//新购物车只是取其商品ID与数量等
            M_Product proMod     = proBll.GetproductByid(newCartMod.ProID);
            //更新延长旧服务的到期时间,旧服务是存在CartPro的EndTime当中
            M_CartPro oldCartMod = cartBll.SelReturnModel(Convert.ToInt32(mod.Ordermessage));
            if (oldCartMod.EndTime < DateTime.Now)
            {
                oldCartMod.EndTime = DateTime.Now;                                   //如已过期,则将时间更新至今日
            }
            oldCartMod.EndTime = proBll.GetEndTime(proMod, newCartMod.Pronum, oldCartMod.EndTime);
            cartBll.UpdateByID(oldCartMod);
            //paylogMod.Remind = "为" + mod.Ordermessage + "订单续费(购物车)";
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Cloud)//云购订单
        {
            //根据份数生成幸运码,写入表中,并减去库存 ZL_Order_LuckCode
        }
        else//其他旅游订单等,只更新状态
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);//成功的订单
        }
        //-------支付成功处理,并写入日志
        paylogMod.Remind   += "订单" + mod.OrderNo + "购买生效";
        paylogMod.OrderID   = mod.id;
        paylogMod.PayMoney  = mod.Ordersamount;
        paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;//外部指定
        paylogMod.PayPlatID = pinfo.PayPlatID;
        paylogBll.insert(paylogMod);
    }
Esempio n. 2
0
        /// <summary>
        /// 异步回调后-->验证支付单状态-->如果正常,更新订单状态
        /// 多张订单在外层循环,这里只处理单订单
        /// </summary>
        /// <param name="mod">订单模型</param>
        /// <param name="paylogMod">订单支付日志模型</param>
        public static void FinalStep(M_Payment pinfo, M_OrderList mod, M_Order_PayLog paylogMod)
        {
            B_Order_PayLog paylogBll = new B_Order_PayLog();
            B_User         buser     = new B_User();

            //订单已处理,避免重复(如已处理过,则继续处理下一张订单)
            if (mod.OrderStatus >= 99)
            {
                ZLLog.L(Model.ZLEnum.Log.safe, new M_Log()
                {
                    Action  = "支付回调异常,订单状态已为99",
                    Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo
                });
                return;
            }
            //已经收到钱了,所以先执行(如多订单,则该值需要看支付单)
            orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + pinfo.MoneyTrue, mod.id);
            if (mod.Ordertype == (int)M_OrderList.OrderEnum.Domain)//域名订单
            {
                orderBll.UpOrderinfo("OrderStatus=1,PaymentNo='" + pinfo.PayNo + "'", mod.id);
                //Response.Redirect("~/Plugins/Domain/DomReg2.aspx?OrderNo=" + mod.OrderNo);
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.IDC)//IDC服务
            {
                B_Order_IDC idcBll = new B_Order_IDC();
                orderBll.FinishOrder(mod.id, pinfo);
                idcBll.UpdateEndTimeByNo(mod.OrderNo);
            }
            else if ((mod.Ordertype == (int)M_OrderList.OrderEnum.IDCRen))//IDC服务续费
            {
                B_Order_IDC idcBll = new B_Order_IDC();
                orderBll.FinishOrder(mod.id, pinfo);
                idcBll.RennewTime(mod);
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Purse)//余额充值,不支持银币
            {
                buser.ChangeVirtualMoney(mod.Userid, new M_UserExpHis()
                {
                    score     = mod.Ordersamount,
                    ScoreType = (int)M_UserExpHis.SType.Purse,
                    detail    = "余额充值,订单号:" + mod.OrderNo
                });
                orderBll.FinishOrder(mod.id, pinfo);                    //成功的订单
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Cloud) //虚拟商品订单
            {
                orderBll.FinishOrder(mod.id, pinfo);
            }
            else//其他旅游订单等,只更新状态
            {
                orderBll.FinishOrder(mod.id, pinfo);//成功的订单
            }
            //-------支付成功处理,快照并写入日志
            SaveSnapShot(mod);
            paylogMod.Remind   += "订单" + mod.OrderNo + "购买生效";
            paylogMod.OrderID   = mod.id;
            paylogMod.PayMoney  = mod.Ordersamount;
            paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;//外部指定
            paylogMod.PayPlatID = pinfo.PayPlatID;
            paylogBll.insert(paylogMod);
            //------商品是否赠送积分
            {
                DataTable prodt = DBCenter.JoinQuery("A.ProID,B.PointVal", "ZL_CartPro", "ZL_Commodities", "A.ProID=B.ID", "A.OrderListID=" + mod.id);
                foreach (DataRow dr in prodt.Rows)
                {
                    double point = DataConvert.CDouble(dr["PointVal"]);
                    if (point > 0)
                    {
                        buser.AddMoney(mod.Userid, point, M_UserExpHis.SType.Point, "购买商品[" + dr["ProID"] + "],赠送积分");
                    }
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string spliteFlag  = "&signMsg=";
                string requestStr  = Request.Form.ToString();
                string srcStr      = requestStr.Substring(0, requestStr.IndexOf(spliteFlag));
                string signStr     = requestStr.Substring(requestStr.IndexOf(spliteFlag) + spliteFlag.Length);
                string spliteFlag2 = "&notifyType=";//0为页面通知,1为异步通知
                int    pos         = signStr.IndexOf(spliteFlag2);
                if (pos > 0)
                {
                    signStr = signStr.Substring(0, pos);
                }
                else
                {
                    pos = srcStr.IndexOf(spliteFlag2);
                    if (pos > 0)
                    {
                        srcStr = srcStr.Substring(0, pos);
                    }
                }
                signStr = System.Web.HttpUtility.UrlDecode(signStr);
                bool verifyResult = Mobo360SignUtil.Instance.verifyData(signStr, srcStr);
                //NotifyType 1:异步,0:同步
                //apiName=PAY_RESULT_NOTIFY&notifyTime=20150327093653&tradeAmt=0.01&merchNo=210001110003583&merchParam=&orderNo=PD12&tradeDate=20150327&accNo=761003&accDate=20150327&orderStatus=1&signMsg=YIfQ7JGp4MIe5hu19lEmWF22aM9xcaL5LqMKlddEv4L7V2vv36qtPKwdS40HOLX1aaVHXgCnwoXnHacrXghRxvM3B1yFuKcCC2q5HnRBnN3Pxg%2bmBUt5WKMJwOC6VbJgqAQvW4UYaubVl7V4TGbAoYGjWuuIFWRthAacPdpK%2bH4%3d&notifyType=1
                //apiName=PAY_RESULT_NOTIFY&notifyTime=20150327094538&tradeAmt=0.01&merchNo=210001110003583&merchParam=&orderNo=PD13&tradeDate=20150327&accNo=761140&accDate=20150327&orderStatus=1&notifyType=0&signMsg=dIUoegWS2HgtHlHwz1i62oYPfGyqgNi5HW%2bew734APG0O9xKLHXbR9atFDxwZpXtovQ7wjPuYgqtwD0R0VsNIr5ceA8dlRETepKo0D8Gi1Z4iGtW3UZ%2f92T8ILMRXEw3fUOMTMxyxk265A0VlAla9pCqMMd8QC5pxNoPWOwKFfo%3d
                #region 校验并更改状态
                //if (verifyResult)//其无法通过自己校验
                //{

                //}
                //else { B_Site_Log.Insert("MO宝校验失败", requestStr); }
                string     orderNo    = Request.Form["orderNo"];//订单号
                string     notifyType = Request.Form["notifyType"];
                double     tradeAmt   = DataConverter.CDouble(Request.Form["tradeAmt"]);
                M_UserInfo mu         = buser.GetLogin(false);
                try
                {
                    if (notifyType.Equals("0"))
                    {
                        function.WriteErrMsg("支付成功"); return;
                    }
                    if (notifyType.Equals("1"))
                    {
                        M_Payment pinfo = payBll.SelModelByPayNo(orderNo);
                        if (pinfo.Status == 3)
                        {
                            return;
                        }
                        pinfo.Status       = 3;
                        pinfo.PlatformInfo = "MO宝在线付款";
                        pinfo.SuccessTime  = DateTime.Now;
                        pinfo.PayTime      = DateTime.Now;
                        pinfo.CStatus      = true;
                        pinfo.MoneyTrue    = tradeAmt;
                        payBll.Update(pinfo);
                        DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                        foreach (DataRow dr in orderDT.Rows)
                        {
                            M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                            if (orderMod.OrderStatus >= 99)
                            {
                                return;                            //订单已处理,避免重复
                            }
                            else
                            {
                                orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + tradeAmt, orderMod.id);
                            }
                            orderCom.SendMessage(orderMod, paylogMod, "payed");
                            paylogMod.Remind += "订单" + orderMod.OrderNo + "购买生效";
                            FinalStep(orderMod);
                            //-------支付成功处理,并写入日志
                            paylogMod.OrderID   = orderMod.id;
                            paylogMod.UserID    = mu.UserID;
                            paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;
                            paylogMod.PayMoney  = orderMod.Ordersamount;
                            paylogMod.PayPlatID = 16;
                            paylogBll.insert(paylogMod);
                            Response.Write("SUCCESS"); // 验证签名通过后,商户系统回写“SUCCESS”以表明商户收到了通知
                            B_Site_Log.Insert(pinfo.PaymentNum + ":MO宝处理成功", "状态:" + requestStr);
                        }
                    }
                }
                catch (Exception ex) { B_Site_Log.Insert(orderNo + ":MO宝支付处理失败", "原因:" + ex.Message + ":" + requestStr); }
                #endregion
            }
        }
Esempio n. 4
0
        //支付单虚拟币付款
        private void PayByVirtualMoney(string payMethod, M_Payment payMod)
        {
            M_UserInfo         mui       = buser.GetLogin(false);
            List <M_OrderList> orderList = OrderHelper.OrdersCheck(payMod);

            ActualAmount.Visible = false;
            paylogMod.UserID     = mui.UserID;
            switch (payMethod)//完成支付
            {
            case "Purse":
                if (!SiteConfig.SiteOption.SiteID.Contains("purse"))
                {
                    function.WriteErrMsg("管理员已关闭余额支付功能!");
                }
                if (mui.Purse < (double)payMod.MoneyReal)
                {
                    function.WriteErrMsg("对不起,余额不足! 请<a href='/PayOnline/OrderPay.aspx?Money=" + payMod.MoneyReal + "' target='_blank' style='margin-left:5px;color:#f00;'>充值!</a>");
                }
                buser.ChangeVirtualMoney(mui.UserID, new M_UserExpHis()
                {
                    score     = -(double)payMod.MoneyReal,
                    ScoreType = (int)M_UserExpHis.SType.Purse,
                    detail    = "支付成功,支付单号:" + payMod.PayNo
                });
                mui       = buser.GetLogin(false);
                zfpt.Text = "余额";
                fees.Text = "帐户余额:";
                sxf.Text  = mui.Purse + " 元";
                break;

            case "SilverCoin":
                if (!SiteConfig.SiteOption.SiteID.Contains("sicon"))
                {
                    function.WriteErrMsg("管理员已关闭银币支付功能!");
                }
                if (mui.SilverCoin < (double)payMod.MoneyReal)
                {
                    function.WriteErrMsg("对不起,银币不足!");
                }
                buser.ChangeVirtualMoney(mui.UserID, new M_UserExpHis()
                {
                    score     = -(double)payMod.MoneyReal,
                    ScoreType = (int)M_UserExpHis.SType.SIcon,
                    detail    = "支付成功,支付单号:" + payMod.PayNo
                });
                mui       = buser.GetLogin(false);
                zfpt.Text = "银币";
                fees.Text = "帐户银币:";
                sxf.Text  = mui.SilverCoin + " 个";
                break;

            case "Score":
                if (!SiteConfig.SiteOption.SiteID.Contains("point"))
                {
                    function.WriteErrMsg("管理员已关闭积分支付功能!");
                }
                if (mui.UserExp < (double)payMod.MoneyReal)
                {
                    function.WriteErrMsg("对不起,积分不足!");
                }
                buser.ChangeVirtualMoney(mui.UserID, new M_UserExpHis()
                {
                    score     = -(double)payMod.MoneyReal,
                    ScoreType = (int)M_UserExpHis.SType.Point,
                    detail    = "支付成功,支付单号:" + payMod.PayNo
                });
                mui       = buser.GetLogin(false);
                zfpt.Text = "积分";
                fees.Text = "帐户积分:";
                sxf.Text  = mui.UserExp + " 分";
                break;

            default:
                function.WriteErrMsg("指定的支付方式不存在,请检查大小写是否正确!");
                break;
            }
            for (int i = 0; i < orderList.Count; i++)//更改订单状态
            {
                M_OrderList orderMod = orderList[i];
                OrderHelper.SaveSnapShot(orderMod);
                #region 写入日志,更新订单状态
                switch (payMethod)
                {
                case "Purse":
                    orderMod.Paymentstatus     = (int)M_OrderList.PayEnum.HasPayed;
                    orderMod.Receivablesamount = orderMod.Ordersamount;
                    if (orderBll.Update(orderMod))
                    {
                        orderCom.SendMessage(orderMod, paylogMod, "payed");
                        paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Purse;
                        paylogMod.Remind   += "商城订单" + orderMod.OrderNo + "余额付款成功";
                    }
                    break;

                case "SilverCoin":
                    orderMod.Paymentstatus     = (int)M_OrderList.PayEnum.HasPayed;
                    orderMod.Receivablesamount = orderMod.Ordersamount;
                    if (orderBll.Update(orderMod))
                    {
                        orderCom.SendMessage(orderMod, paylogMod, "payed");
                        paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Silver;
                        paylogMod.Remind   += "商城订单" + orderMod.OrderNo + "银币付款成功";
                    }
                    break;

                case "Score":
                    orderMod.Paymentstatus     = (int)M_OrderList.PayEnum.HasPayed;
                    orderMod.Receivablesamount = orderMod.Ordersamount;
                    if (orderBll.Update(orderMod))
                    {
                        orderCom.SendMessage(orderMod, paylogMod, "payed");
                        paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Score;
                        paylogMod.Remind    = "商城订单" + orderMod.OrderNo + "积分付款成功";
                    }
                    break;

                default:
                    function.WriteErrMsg("指定的支付方式不存在,请检查大小写是否正确!");
                    break;
                }
                //-----------------------付款后处理区域
                //orderCom.SaveSnapShot(orderMod);
                paylogMod.UserID    = mui.UserID;
                paylogMod.OrderID   = orderMod.id;
                paylogMod.PayMoney  = orderMod.Ordersamount;
                paylogMod.PayPlatID = 0;
                OrderHelper.FinalStep(orderMod);//支付成功后处理步步骤,允许操作paylogMod
                paylogBll.insert(paylogMod);
                #endregion
            }
            //-----------------For End
            ddh.Text         = payMod.PaymentNum;
            PayNum_L2.Text   = payMod.MoneyReal.ToString("f2");
            sjhbje.Text      = payMod.MoneyReal.ToString("f2");
            payMod.Status    = (int)M_Payment.PayStatus.HasPayed;
            payMod.MoneyTrue = payMod.MoneyReal;
            paymentBll.Update(payMod);
            payinfo_div.Visible = false;
            AfterPay_Tb.Visible = true;
        }