Exemplo n.º 1
0
        public static void Completed(IAsyncResult result)
        {
            //获取委托对象,调用EndInvoke方法获取运行结果
            AsyncResult           _result    = (AsyncResult)result;
            AsyncsendEventHandler myDelegate = (AsyncsendEventHandler)_result.AsyncDelegate;

            myDelegate.EndInvoke(_result);
        }
Exemplo n.º 2
0
        delegate void AsyncsendEventHandler(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comid, int validateticketlogid, int aorderid);//发送验证同步发送请求委托

        /// <summary>
        /// 阳光验证通知接口
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string xml = context.Request["xml"].ConvertTo <string>("");

            if (xml == "")
            {
                context.Response.Write("fail 接收参数为空");//参数为空
                return;
            }

            if (xml != "")
            {
                //录入交互日志
                ApiLog mapilog = new ApiLog
                {
                    Id            = 0,
                    request_type  = "sync_order",
                    Serviceid     = 1,
                    Str           = xml.Trim(),
                    Subdate       = DateTime.Now,
                    ReturnStr     = "",
                    ReturnSubdate = DateTime.Now,
                    Errmsg        = "",
                };
                int ins = new ApiLogData().EditLog(mapilog);
                mapilog.Id = ins;

                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xml);
                    XmlElement root             = doc.DocumentElement;
                    string     request_type     = root.SelectSingleNode("request_type").InnerText;
                    string     req_seq          = root.SelectSingleNode("req_seq").InnerText;          //原订单流水号
                    string     platform_req_seq = root.SelectSingleNode("platform_req_seq").InnerText; //平台请求流水号
                    string     order_num        = root.SelectSingleNode("order/order_num").InnerText;  //订单号
                    string     num      = root.SelectSingleNode("order/num").InnerText;                //使用张数
                    string     use_time = root.SelectSingleNode("order/use_time").InnerText;           //使用时间

                    //根据平台订单号得到易城订单号
                    int orderid = new B2bOrderData().GetOrderidByServiceOrderNum(order_num);
                    if (orderid == 0)
                    {
                        //"老系统订单,服务商订单信息获取不到"===只有阳光订单才有这种可能,其他接口则直接返回错误
                        //把验票记录 记入 验证同步日志表
                        Api_yg_Syncordernotice notice = new Api_yg_Syncordernotice
                        {
                            id               = 0,
                            req_seq          = req_seq,
                            platform_req_seq = platform_req_seq,
                            order_num        = order_num,
                            num              = num.ConvertTo <int>(0),
                            use_time         = use_time.ConvertTo <DateTime>(),
                            rcontent         = "老系统订单,服务商订单信息获取不到",
                            orderid          = 0
                        };
                        int insnotice = new Api_yg_SyncordernoticeData().EditNotice(notice);
                        notice.id = insnotice;

                        mapilog.ReturnStr     = "success";
                        mapilog.ReturnSubdate = DateTime.Now;
                        mapilog.Errmsg        = notice.rcontent;
                        new ApiLogData().EditLog(mapilog);

                        context.Response.Write("success");
                        return;
                    }

                    //根据平台流水号 得到正确处理的验证通知记录
                    Api_yg_Syncordernotice sucnotice = new Api_yg_SyncordernoticeData().GetSucNotice(platform_req_seq);
                    if (sucnotice == null)
                    {
                        //把验票记录 记入 验证同步日志表
                        Api_yg_Syncordernotice notice = new Api_yg_Syncordernotice
                        {
                            id               = 0,
                            req_seq          = req_seq,
                            platform_req_seq = platform_req_seq,
                            order_num        = order_num,
                            num              = num.ConvertTo <int>(0),
                            use_time         = use_time.ConvertTo <DateTime>(),
                            rcontent         = "",
                            orderid          = orderid
                        };
                        int insnotice = new Api_yg_SyncordernoticeData().EditNotice(notice);
                        notice.id = insnotice;



                        //易城系统订单 处理
                        B2b_order morder = new B2bOrderData().GetOrderById(orderid);
                        if (morder != null)
                        {
                            int incount  = morder.U_num;                                     //总数量
                            int usecount = morder.service_usecount + num.ConvertTo <int>(0); //验证数量
                            if (incount == usecount)                                         //全部验证
                            {
                                morder.service_usecount   = usecount;
                                morder.service_lastcount  = incount - usecount - morder.Cancelnum;
                                morder.Servicepro_v_state = ((int)Product_V_State.AllValidate).ToString(); //验证全部
                                morder.Order_state        = (int)OrderStatus.HasUsed;                      //已消费

                                new B2bOrderData().InsertOrUpdate(morder);
                            }
                            else //部分验证
                            {
                                morder.service_usecount   = usecount;
                                morder.service_lastcount  = incount - usecount - morder.Cancelnum;
                                morder.Servicepro_v_state = ((int)Product_V_State.PartValidate).ToString(); //验证部分
                                morder.Order_state        = (int)OrderStatus.HasUsed;                       //已消费

                                new B2bOrderData().InsertOrUpdate(morder);
                            }

                            //根据b单判断是否有a单存在
                            B2b_order aorder = new B2bOrderData().GetOldorderBybindingId(morder.Id);
                            if (aorder != null)
                            {
                                aorder.Order_state = morder.Order_state;

                                new B2bOrderData().InsertOrUpdate(aorder);
                            }

                            notice.rcontent = "success";
                            new Api_yg_SyncordernoticeData().EditNotice(notice);


                            //如果是分销订单,则需要给分销发送验证通知
                            //判断b订单 是否 属于某个a订单
                            if (aorder != null)
                            {
                                //得到a订单的分销信息
                                if (aorder.Agentid > 0)
                                {
                                    Agent_company acompany = new AgentCompanyData().GetAgentCompany(aorder.Agentid);
                                    if (acompany != null)
                                    {
                                        //异步发送验证同步请求
                                        AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                        mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), morder.Pno, morder.service_usecount, use_time, aorder.Agentid, aorder.Comid, 0, aorder.Id, new AsyncCallback(Completed), null);
                                    }
                                }
                            }
                            else
                            {
                                if (morder.Agentid > 0)
                                {
                                    Agent_company acompany = new AgentCompanyData().GetAgentCompany(morder.Agentid);
                                    if (acompany != null)
                                    {
                                        //异步发送验证同步请求
                                        AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                        mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), morder.Pno, morder.service_usecount, use_time, morder.Agentid, morder.Comid, 0, morder.Id, new AsyncCallback(Completed), null);
                                    }
                                }
                            }

                            mapilog.ReturnStr     = "success";
                            mapilog.ReturnSubdate = DateTime.Now;
                            mapilog.Errmsg        = "成功";
                            new ApiLogData().EditLog(mapilog);

                            context.Response.Write("success");
                            return;
                        }
                        else
                        {
                            mapilog.ReturnStr     = "fail 获取订单失败";
                            mapilog.ReturnSubdate = DateTime.Now;
                            mapilog.Errmsg        = "fail 获取订单失败";
                            new ApiLogData().EditLog(mapilog);

                            notice.rcontent = "fail 获取订单失败";
                            new Api_yg_SyncordernoticeData().EditNotice(notice);

                            context.Response.Write("fail 获取订单失败");
                            return;
                        }
                    }
                    else
                    {
                        mapilog.ReturnStr     = "success";
                        mapilog.ReturnSubdate = DateTime.Now;
                        mapilog.Errmsg        = "已经成功处理过,不在处理";
                        new ApiLogData().EditLog(mapilog);

                        context.Response.Write("success");
                        return;
                    }
                }
                catch
                {
                    context.Response.Write("fail 意外错误");//意外错误
                    return;
                }
            }
        }
Exemplo n.º 3
0
        delegate void AsyncsendEventHandler(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comid, int validateticketlogid, int aorderid);//发送验证同步发送请求委托

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string xml = Request["xml"].ToString();
                //string xml = "rzChHB2sU9ld7U8YJm+ehw3aukqIGDM4BtqU0aUKqsh0Wlv7lE7QY0h+6TyATqOKSH7pPIBOo4pIfuk8gE6jikh+6TyATqOK88GTsYxHp+jxFjUWFoOLabGkQCK4I/78+O3AIZim06QMwlqxUloGSwUMhENjECcrzbztXnARK88eCV0nzDbYTSXGBvHHQSpCtYsGXg/lwRreR77JNU04PrnA/lhi3vGqrkNT1h37aYFq1/tYQ1Xz/ZZH12+3kc7eN5HVgtJCsazTnwU3IXzBtgTaJ2ESK0/X0ncZdJ1sFl4cdnO/KompxrjYGhqFw7FIjsFUOFy3n1dNbNhZIFe8Y78Lir83nuy1W7A/bsAjwDoqCCTzSMhu4i1fpj0wiwQw2BdtiUN3SUQvOPw+mKMgINlGNcH6G0/KSglfJdF6P3DNfmxtL8FfbNt6uk7GCtoKHZD21Lc7H95at7dJ0msz8Y+YwVrIaCGc";
                //string xml = "<?xml version='1.0' encoding='UTF-8'?><Body><type>use_info</type><orderId>22221</orderId><outOrderId>126079</outOrderId><credence>991553361205</credence><useCount>1</useCount><lastCount>0</lastCount><useTime>2015-10-21 17:31:42</useTime><exchangeId>16504001</exchangeId><postTime>2015-10-21 17:33:00</postTime></Body>";
                if (xml == "")
                {
                    TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\mjldlog.txt", "xml空");

                    Response.Write("fail 接收参数为空");

                    return;
                }
                if (xml != "")
                {
                    TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\mjldlog.txt", xml);

                    ApiService mapiservice = new ApiServiceData().GetApiservice(3);
                    if (mapiservice == null)
                    {
                        TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\mjldlog.txt", "获取服务商信息失败-" + xml);

                        Response.Write("fail 获取服务商信息失败");

                        return;
                    }
                    xml = Mjld_TCodeServiceCrypt.Decrypt3DESFromBase64(xml, mapiservice.Deskey);
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(xml.Trim());
                        XmlElement root = doc.DocumentElement;

                        string type = root.SelectSingleNode("type").InnerText;

                        //验证推送
                        if (type == "use_info")
                        {
                            TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\mjldlog.txt", "use_info: " + xml);


                            //录入交互日志
                            ApiLog mapilog = new ApiLog
                            {
                                Id            = 0,
                                request_type  = "use_info",
                                Serviceid     = 3,
                                Str           = xml.Trim(),
                                Subdate       = DateTime.Now,
                                ReturnStr     = "",
                                ReturnSubdate = DateTime.Now,
                                Errmsg        = "",
                            };
                            int ins = new ApiLogData().EditLog(mapilog);

                            //平台订单号
                            string MjldorderId = root.SelectSingleNode("orderId").InnerText;
                            //合作伙伴订单号
                            string orderid = root.SelectSingleNode("outOrderId").InnerText;
                            //验证码
                            string credence = root.SelectSingleNode("credence").InnerText;
                            //使用数量
                            string useCount = root.SelectSingleNode("useCount").InnerText;
                            //剩余数量
                            string lastCount = root.SelectSingleNode("lastCount").InnerText;
                            //验证使用时间
                            string useTime = root.SelectSingleNode("useTime").InnerText;
                            //验证ID
                            string exchangeId = root.SelectSingleNode("exchangeId").InnerText;
                            //景区ID
                            //string ScenicId = root.SelectSingleNode("ScenicId").InnerText;
                            string ScenicId = "";
                            //推送时间
                            string postTime = root.SelectSingleNode("postTime").InnerText;

                            //根据验证id判断是否已经成功处理过该验证推送
                            Api_mjld_AsyncUsenotice sucnotice = new Api_mjld_AsyncUsenoticeData().GetSucUseNoticeByExchangeId(exchangeId);
                            if (sucnotice == null)
                            {
                                Api_mjld_AsyncUsenotice usenotice = new Api_mjld_AsyncUsenotice
                                {
                                    id          = 0,
                                    type        = type,
                                    mjldOrderId = MjldorderId,
                                    credence    = credence,
                                    useCount    = useCount.ConvertTo <int>(0),
                                    lastCount   = lastCount.ConvertTo <int>(0),
                                    useTime     = useTime,
                                    exchangeId  = exchangeId,
                                    ScenicId    = ScenicId,
                                    postTime    = postTime,
                                    rcontent    = "",
                                    orderId     = orderid.ConvertTo <int>(0),
                                };
                                int insUsenotice = new Api_mjld_AsyncUsenoticeData().EditUsenotice(usenotice);
                                usenotice.id = insUsenotice;

                                //易城系统订单 处理
                                B2b_order morder = new B2bOrderData().GetOrderById(orderid.ConvertTo <int>(0));
                                if (morder != null)
                                {
                                    if (lastCount.ConvertTo <int>(0) > 0)
                                    {
                                        int usecount = morder.service_usecount + usenotice.useCount;
                                        morder.service_usecount   = usecount;
                                        morder.service_lastcount  = usenotice.lastCount;
                                        morder.Servicepro_v_state = ((int)Product_V_State.PartValidate).ToString(); //验证部分

                                        morder.Order_state = (int)OrderStatus.HasUsed;                              //已消费

                                        new B2bOrderData().InsertOrUpdate(morder);
                                    }
                                    else
                                    {
                                        int usecount = morder.service_usecount + usenotice.useCount;
                                        morder.service_usecount   = usecount;
                                        morder.service_lastcount  = usenotice.lastCount;
                                        morder.Servicepro_v_state = ((int)Product_V_State.AllValidate).ToString(); //验证全部

                                        morder.Order_state = (int)OrderStatus.HasUsed;                             //已消费

                                        new B2bOrderData().InsertOrUpdate(morder);
                                    }

                                    //根据b单判断是否有a单存在
                                    B2b_order aorder = new B2bOrderData().GetOldorderBybindingId(morder.Id);
                                    if (aorder != null)
                                    {
                                        aorder.Order_state = morder.Order_state;

                                        new B2bOrderData().InsertOrUpdate(aorder);
                                    }

                                    usenotice.rcontent = "1";
                                    new Api_mjld_AsyncUsenoticeData().EditUsenotice(usenotice);

                                    //如果是分销订单,则需要给分销发送验证通知
                                    //判断b订单 是否 属于某个a订单
                                    if (aorder != null)
                                    {
                                        //得到a订单的分销信息
                                        if (aorder.Agentid > 0)
                                        {
                                            Agent_company acompany = new AgentCompanyData().GetAgentCompany(aorder.Agentid);
                                            if (acompany != null)
                                            {
                                                //异步发送验证同步请求
                                                AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                                mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), credence, int.Parse(useCount), useTime, aorder.Agentid, aorder.Comid, 0, aorder.Id, new AsyncCallback(Completed), null);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (morder.Agentid > 0)
                                        {
                                            Agent_company acompany = new AgentCompanyData().GetAgentCompany(morder.Agentid);
                                            if (acompany != null)
                                            {
                                                //异步发送验证同步请求
                                                AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                                mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), credence, int.Parse(useCount), useTime, morder.Agentid, morder.Comid, 0, morder.Id, new AsyncCallback(Completed), null);
                                            }
                                        }
                                    }



                                    Response.Write("1");


                                    return;
                                }
                                else
                                {
                                    usenotice.rcontent = "fail 获取订单失败";
                                    new Api_mjld_AsyncUsenoticeData().EditUsenotice(usenotice);

                                    Response.Write("fail");

                                    return;
                                }
                            }
                            else
                            {
                                Response.Write("1");

                                return;
                            }
                        }
                        //退票推送
                        if (type == "back_order")
                        {
                            TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\mjldlog.txt", "back_order: " + xml);


                            //录入交互日志
                            ApiLog mapilog = new ApiLog
                            {
                                Id            = 0,
                                request_type  = "back_order",
                                Serviceid     = 3,
                                Str           = xml.Trim(),
                                Subdate       = DateTime.Now,
                                ReturnStr     = "",
                                ReturnSubdate = DateTime.Now,
                                Errmsg        = "",
                            };
                            int ins = new ApiLogData().EditLog(mapilog);


                            //2为退单成功 3为拒绝
                            string backStatus = root.SelectSingleNode("backStatus").InnerText;
                            //外部退单id
                            string outBackId = root.SelectSingleNode("outBackId").InnerText;
                            //成功退货数量
                            string backCount = root.SelectSingleNode("backCount").InnerText;


                            //本平台退单id
                            string backId = root.SelectSingleNode("backId").InnerText;
                            //推送时间
                            string postTime = root.SelectSingleNode("postTime").InnerText;

                            //根据mjldorderid判断是否成功处理过
                            Api_mjld_AsyncBacknotice sucnotice = new Api_mjld_AsyncBacknoticeData().GetSucApi_mjld_AsyncBacknotice(backId);
                            if (sucnotice == null)
                            {
                                Api_mjld_AsyncBacknotice backnotice = new Api_mjld_AsyncBacknotice
                                {
                                    id          = 0,
                                    mjldorderid = backId,
                                    orderid     = outBackId.ConvertTo <int>(0),
                                    backCount   = backCount.ConvertTo <int>(0),
                                    backStatus  = backStatus.ConvertTo <int>(0),
                                    postTime    = postTime,
                                    rcontent    = "",
                                    type        = type
                                };
                                int insBacknotice = new Api_mjld_AsyncBacknoticeData().EditBacknotice(backnotice);
                                backnotice.id = insBacknotice;

                                //易城系统订单
                                B2b_order morder = new B2bOrderData().GetOrderById(outBackId.ConvertTo <int>(0));
                                if (morder != null)
                                {
                                    //只有订单状态 为"退票处理中",才会进行退款操作
                                    if (morder.Order_state == (int)OrderStatus.WaitQuitOrder)
                                    {
                                        if (backStatus == "2")
                                        {
                                            OrderJsonData.QuitOrder(0, outBackId.ConvertTo <int>(0), morder.Pro_id, backCount.ConvertTo <int>(0), "");
                                        }
                                        //拒绝退款 则还原原来订单状态;订单备注中 提示“拒绝退款”
                                        if (backStatus == "3")
                                        {
                                            //判断是否有订单 绑定传入的订单
                                            B2b_order d_loldorder = new B2bOrderData().GetOldorderBybindingId(outBackId.ConvertTo <int>(0));
                                            if (d_loldorder != null)
                                            {
                                                d_loldorder.Order_state  = (morder.Order_remark).ConvertTo <int>(0);
                                                d_loldorder.Order_remark = "美景联动拒绝退票";

                                                new B2bOrderData().UpOrderStateAndRemark(d_loldorder.Id, d_loldorder.Order_state, d_loldorder.Order_remark);
                                            }

                                            morder.Order_state  = (morder.Order_remark).ConvertTo <int>(0);;
                                            morder.Order_remark = "美景联动拒绝退票";
                                            new B2bOrderData().UpOrderStateAndRemark(morder.Id, morder.Order_state, morder.Order_remark);
                                        }

                                        backnotice.rcontent = "1";
                                        new Api_mjld_AsyncBacknoticeData().EditBacknotice(backnotice);

                                        Response.Write("1");

                                        return;
                                    }
                                    else
                                    {
                                        backnotice.rcontent = "fail 订单状态应该为(退票处理中),可是现在为:" + EnumUtils.GetName((OrderStatus)morder.Order_state);
                                        new Api_mjld_AsyncBacknoticeData().EditBacknotice(backnotice);

                                        Response.Write("fail");

                                        return;
                                    }
                                }
                                else
                                {
                                    backnotice.rcontent = "fail 获取订单失败";
                                    new Api_mjld_AsyncBacknoticeData().EditBacknotice(backnotice);

                                    Response.Write("fail");

                                    return;
                                }
                            }
                            else
                            {
                                Response.Write("1");


                                return;
                            }
                        }
                    }
                    catch
                    {
                        Response.Write("fail");

                        return;
                    }
                }
            }
            catch
            {
                Response.Write("fail 接收参数为空");

                return;
            }
        }
Exemplo n.º 4
0
        delegate void AsyncsendEventHandler(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comid, int validateticketlogid, int aorderid);//发送验证同步发送请求委托

        public void ProcessRequest(HttpContext context)
        {
            //B2b_company commanage = B2bCompanyData.GetAllComMsg(112);
            WlGetProInfoDealRequestData wldata = new WlGetProInfoDealRequestData("1", "key");//核销数据时不需要读取商户
            int comid = 0;

            context.Response.ContentType = "application/x-www-form-urlencoded";
            Stream stream = context.Request.InputStream;

            if (stream.Length != 0)
            {
                try
                {
                    StreamReader streamreader = new StreamReader(stream);
                    string       json         = streamreader.ReadToEnd();
                    //var OnlineMsg = StreamToString(stream);
                    // context.Response.Write(OnlineMsg);
                    // context.Response.End();
                    var    json_hexiao      = (wlhexiao)JsonConvert.DeserializeObject(json, typeof(wlhexiao));
                    int    partnerId        = json_hexiao.partnerId;
                    string wlOrderId        = json_hexiao.body.wlOrderId;
                    int    usedQuantity     = json_hexiao.body.usedQuantity;
                    int    quantity         = json_hexiao.body.quantity;
                    int    refundedQuantity = json_hexiao.body.refundedQuantity;
                    int    lastCount        = 0;
                    string credence         = "";

                    var orderdata = wldata.getWlOrderidData(wlOrderId);
                    if (orderdata != null)
                    {
                        comid    = orderdata.comid;
                        credence = orderdata.vouchers;
                        int orderid       = orderdata.orderid;       //orderid
                        int partnerdealid = orderdata.partnerdealid; //产品id
                        int shengyuq      = orderdata.quantity - orderdata.usedQuantity;
                        lastCount = shengyuq - usedQuantity;         //剩余数量看是否大于0


                        //插入万龙核销日志插入
                        var wluselog = wldata.InsertWlUseLog(comid, wlOrderId, usedQuantity, partnerId, quantity, orderid, partnerdealid);


                        if (shengyuq >= usedQuantity)
                        {
                            orderdata.usedQuantity = orderdata.usedQuantity + usedQuantity;//库里的剩余数量加上传递过来使用数量

                            var hexiao = wldata.UpdateWlOrderPaySC(orderdata);

                            var wlhexiaore = wldata.wlhexiaotongzhi_json(200, "成功");//
                            context.Response.Write(wlhexiaore);



                            #region 验证后订单及通知发放
                            //易城系统订单 处理
                            B2b_order morder = new B2bOrderData().GetOrderById(orderid);
                            if (morder != null)
                            {
                                if (lastCount > 0)
                                {
                                    morder.service_usecount   = usedQuantity;
                                    morder.service_lastcount  = lastCount;
                                    morder.Servicepro_v_state = ((int)Product_V_State.PartValidate).ToString(); //验证部分

                                    morder.Order_state = (int)OrderStatus.HasUsed;                              //已消费

                                    new B2bOrderData().InsertOrUpdate(morder);
                                }
                                else
                                {
                                    //如果剩余数量为0就,使都使用了,剩余数量为0
                                    morder.service_usecount   = usedQuantity;
                                    morder.service_lastcount  = 0;
                                    morder.Servicepro_v_state = ((int)Product_V_State.AllValidate).ToString(); //验证全部

                                    morder.Order_state = (int)OrderStatus.HasUsed;                             //已消费

                                    new B2bOrderData().InsertOrUpdate(morder);
                                }

                                //根据b单判断是否有a单存在
                                B2b_order aorder = new B2bOrderData().GetOldorderBybindingId(morder.Id);
                                if (aorder != null)
                                {
                                    aorder.Order_state = morder.Order_state;

                                    new B2bOrderData().InsertOrUpdate(aorder);
                                }


                                //如果是分销订单,则需要给分销发送验证通知
                                //判断b订单 是否 属于某个a订单
                                if (aorder != null)
                                {
                                    //得到a订单的分销信息
                                    if (aorder.Agentid > 0)
                                    {
                                        Agent_company acompany = new AgentCompanyData().GetAgentCompany(aorder.Agentid);
                                        if (acompany != null)
                                        {
                                            //异步发送验证同步请求
                                            AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                            mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), credence, usedQuantity, DateTime.Now.ToString(), aorder.Agentid, aorder.Comid, 0, aorder.Id, new AsyncCallback(Completed), null);
                                        }
                                    }
                                }
                                else
                                {
                                    if (morder.Agentid > 0)
                                    {
                                        Agent_company acompany = new AgentCompanyData().GetAgentCompany(morder.Agentid);
                                        if (acompany != null)
                                        {
                                            //异步发送验证同步请求
                                            AsyncsendEventHandler mydelegate = new AsyncsendEventHandler(AsyncSend);
                                            mydelegate.BeginInvoke(acompany.Agent_updateurl.Trim(), credence, usedQuantity, DateTime.Now.ToString(), morder.Agentid, morder.Comid, 0, morder.Id, new AsyncCallback(Completed), null);
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            var wlhexiaore = wldata.wlhexiaotongzhi_json(1, "剩余数量不符");//
                            context.Response.Write(wlhexiaore);
                        }
                    }
                    else
                    {
                        //context.Response.Write("{code:200,describe:\"成功\"}");
                        var wlhexiaore = wldata.wlhexiaotongzhi_json(1, "未查询到订单");//
                        context.Response.Write(wlhexiaore);
                    }
                }
                catch (Exception ex) {
                    var wlhexiaore = wldata.wlhexiaotongzhi_json(1, "异常" + ex.Message);//
                    context.Response.Write(wlhexiaore);
                }
            }
            else
            {
                var wlhexiaore = wldata.wlhexiaotongzhi_json(2, "未接收到数据");//
                context.Response.Write(wlhexiaore);
            }
        }