internal Api_mjld_AsyncUsenotice GetSucUseNoticeByExchangeId(string exchangeId) { string sql = "select * from api_mjld_AsyncUsenotice where exchangeId='" + exchangeId + "' and rcontent='1'"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); using (var reader = cmd.ExecuteReader()) { Api_mjld_AsyncUsenotice m = null; if (reader.Read()) { m = new Api_mjld_AsyncUsenotice { id = reader.GetValue <int>("id"), type = reader.GetValue <string>("type"), mjldOrderId = reader.GetValue <string>("mjldOrderId"), credence = reader.GetValue <string>("credence"), useCount = reader.GetValue <int>("useCount"), lastCount = reader.GetValue <int>("lastCount"), useTime = reader.GetValue <string>("useTime"), exchangeId = reader.GetValue <string>("exchangeId"), ScenicId = reader.GetValue <string>("ScenicId"), postTime = reader.GetValue <string>("postTime"), rcontent = reader.GetValue <string>("rcontent"), orderId = reader.GetValue <int>("orderId"), }; } return(m); } }
public int EditUsenotice(Api_mjld_AsyncUsenotice usenotice) { using (var helper = new SqlHelper()) { int m = new Internalapi_mjld_AsyncUsenotice(helper).EditUsenotice(usenotice); return(m); } }
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; } }
internal int EditUsenotice(Api_mjld_AsyncUsenotice m) { if (m.id > 0) { string sql = @"UPDATE [api_mjld_AsyncUsenotice] SET [type] = @type ,[mjldOrderId] = @mjldOrderId ,[credence] = @credence ,[useCount] = @useCount ,[lastCount] = @lastCount ,[useTime] = @useTime ,[exchangeId] = @exchangeId ,[ScenicId] = @ScenicId ,[postTime] = @postTime ,[rcontent] = @rcontent ,[orderId] = @orderId WHERE id=@id"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@id", m.id); cmd.AddParam("@type", m.type); cmd.AddParam("@mjldOrderId", m.mjldOrderId); cmd.AddParam("@credence", m.credence); cmd.AddParam("@useCount", m.useCount); cmd.AddParam("@lastCount", m.lastCount); cmd.AddParam("@useTime", m.useTime); cmd.AddParam("@exchangeId", m.exchangeId); cmd.AddParam("@ScenicId", m.ScenicId); cmd.AddParam("@postTime", m.postTime); cmd.AddParam("@rcontent", m.rcontent); cmd.AddParam("@orderId", m.orderId); cmd.ExecuteNonQuery(); return(m.id); } else { string sql = @"INSERT [api_mjld_AsyncUsenotice] ([type] ,[mjldOrderId] ,[credence] ,[useCount] ,[lastCount] ,[useTime] ,[exchangeId] ,[ScenicId] ,[postTime] ,[rcontent] ,[orderId]) VALUES (@type ,@mjldOrderId ,@credence ,@useCount ,@lastCount ,@useTime ,@exchangeId ,@ScenicId ,@postTime ,@rcontent ,@orderId);select @@identity;"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@type", m.type); cmd.AddParam("@mjldOrderId", m.mjldOrderId); cmd.AddParam("@credence", m.credence); cmd.AddParam("@useCount", m.useCount); cmd.AddParam("@lastCount", m.lastCount); cmd.AddParam("@useTime", m.useTime); cmd.AddParam("@exchangeId", m.exchangeId); cmd.AddParam("@ScenicId", m.ScenicId); cmd.AddParam("@postTime", m.postTime); cmd.AddParam("@rcontent", m.rcontent); cmd.AddParam("@orderId", m.orderId); object o = cmd.ExecuteScalar(); return(int.Parse(o.ToString())); } }