/** * OrderList.aspx.cs * * 功 能: 订单列表 * 类 名: OrderList * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2013-5-6 9:16 吴崎均 初版 * V0.02 2013-5-6 18:02 吴崎均 完成分页查询 * V0.03 2013-5-7 17:28 吴崎均 增加订单状态设置(置为:生产、完成)并加上以限制(如:线上订单不可置为完成)、 * 增加批量删除并予以限制(只能删除未受理的厂商新增订单)、 * 增加受理操作并加以限制(只有未受理的订单才能受理) * * * * */ using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL.EC; using CY.Model; using CY.BLL.Sys; using CY.Infrastructure.Common; using CY.BLL; using CY.WebForm.Pages.common; using System.Transactions; namespace CY.WebForm.Pages.business { /// /// 订单列表界面类 /// public partial class OrderListBatchOperation : BasePage { EC_OrderBasicBLL _eC_OrderBasicBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; LF_OrderFileBLL _lF_OrderFileBLL = null; EC_OrderBLL _eC_OrderBLL = null; OA_KaipiaoshenqingBLL _oA_KaipiaoshenqingBLL = null; OA_CorporateClientsBLL _oA_CorporateClientsBLL = null; /// /// 初始化构造 /// public OrderListBatchOperation() { _eC_OrderBasicBLL = new EC_OrderBasicBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); _lF_OrderFileBLL = new LF_OrderFileBLL(); _eC_OrderBLL = new EC_OrderBLL(); _oA_KaipiaoshenqingBLL = new OA_KaipiaoshenqingBLL(); _oA_CorporateClientsBLL = new OA_CorporateClientsBLL(); } /// /// 加载事件 /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (Request["downId"] != null) { int iDownId = Convert.ToInt32(Request["downId"]); LF_OrderFile model = _lF_OrderFileBLL.GetModel(iDownId); model.FileState = 1; _lF_OrderFileBLL.UpdateModel(model); string fileName = "";//客户端保存的文件名 string filePath = "";//路径 if (model != null) { fileName = model.FileName;//客户端保存的文件名 filePath = model.FilePath;//路径 } else { JavaScript.MessageBox("文件不存在", this); return; } System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); if (fileInfo.Exists == true) { const long ChunkSize = 102400;//100K 每次读取文件,只读取100K,这样可以缓解服务器的压力 byte[] buffer = new byte[ChunkSize]; Response.Clear(); System.IO.FileStream iStream = System.IO.File.OpenRead(filePath); long dataLengthToRead = iStream.Length;//获取下载的文件总大小 Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName)); while (dataLengthToRead > 0 && Response.IsClientConnected) { int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize));//读取的大小 Response.OutputStream.Write(buffer, 0, lengthRead); Response.Flush(); dataLengthToRead = dataLengthToRead - lengthRead; } Response.Close(); } Response.Redirect("/Pages/business/OrderListBatchOperation.aspx"); return; } switch (Request["Target"]) { case "deleteOrderAll2": AcceptAll2(); break; case "deleteOrderAll3": AcceptAll3(); break; case "AcceptOrder": Accept(); break; case "AcceptOrderAll": AcceptAll(); break; case "ChangeState": //ChangeOrderState(); break; case "BatchDelete": CY.WebForm.cs.WebUtil.DeleteData(_eC_OrderBasicBLL.DeleteDataByIds, CurrentUser.ShortName);//调用通用删除方法 break; case "BatchToOver": UpdataState(-1);//设置状态为完成(不能是1'未受理'或2'已受理') break; case "BatchToProduction": //UpdataState(3);//设置状态为生产中(不能是1'未受理'或2'已受理') break; case "BatchToSend": UpdataState(4);//设置状态为已完工 (不能是1'未受理'或2'已受理') break; case "ToAccountDelay": Delay(1);//请求打款延期 break; case "DeliveryDelay": Delay(2);//请求交货延期 break; case "OrderRepeal": Delay(3);//请求撤单 break; case "ReplyRequest"://答复订单请求 RequestReply(); break; case "RetireOrderBySeller": //卖家直接撤单,或者 RetireOrderBySeller(); break; case "CanPrintAwb": CanPrintAwb(); break; default: Page_Load_Default(); return; } } catch (Exception ex) { PAGEHandleException(ex); Response.Clear(); //Response.Write("参数错误"); Response.Write(ex.Message); } Response.End(); } /// /// 判断是否可以批量打印送货单 /// public void CanPrintAwb() { EC_AcceptWayByOrderBLL _AcceptWayByOrderBLL = new EC_AcceptWayByOrderBLL(); string orderIds = Request["orderIds"].ToString(); string[] orderIdArry = orderIds.Split(','); bool IsFirst = true; string firstAccepterAddress = string.Empty; string result = string.Empty; string jsonStr = "IsCan:'true'"; string msg = "只有送货上门且送货地址相同的订单才能打印送货单"; foreach (string orderIdStr in orderIdArry) { int orderId = orderIdStr.ToInt32().Value; EC_AcceptWayByOrder model = _AcceptWayByOrderBLL.GetModelByTargetId(orderId); if (model == null) continue; if (IsFirst) { firstAccepterAddress = model.AccepterAddress.Trim(); } if (model.AcceptTypeId.Value != 106) { jsonStr = "IsCan:'false',Msg:'" + msg + "'"; break; } if (model.AccepterAddress.Trim() != firstAccepterAddress) { jsonStr = "IsCan:'false',Msg:'" + msg + "'"; break; } IsFirst = false; } result = "{" + jsonStr + "}"; Response.Write(result); } /// /// 更新状态 /// private void UpdataState(int stateId) { Response.Clear(); if (1 == stateId || 2 == stateId) { HttpContext.Current.Response.Write(-2); return; } string paramValue = HttpContext.Current.Request["ids"]; //string stateStr=HttpContext.Current.Request["state"]; string remark = string.Format("{0}", Request["remark"]); int? tempId; //tempId = string.IsNullOrEmpty(stateStr)?null:MyConvert.ConvertToInt32(stateStr); if (string.IsNullOrEmpty(paramValue)/*||!tempId.HasValue*/) { HttpContext.Current.Response.Write(-2); return; } else { } //int stateId=tempId.Value; string[] splitResult = paramValue.Split(','); int i = -1; List oprates = new List(); while (++i < splitResult.Length) { tempId = MyConvert.ConvertToInt32(splitResult[i]); if (!tempId.HasValue) { HttpContext.Current.Response.Write(-2); return; } else { } oprates.Add(new EC_OrderOperate() { OperateType = stateId, OrderId = tempId.Value, Operator = CurrentUser.ShortName, Remark = remark }); } HttpContext.Current.Response.Write((_eC_OrderBasicBLL.UpdateOrderState(oprates.ToArray()) ? 1 : 0)); } /// /// 受理订单(全部订单受理) /// private void Accept() { Response.Clear(); PayAbout payAbout = new PayAbout(); payAbout.LoadNewestPaymentAccount(true); double? commission = MyConvert.ConvertToDouble(CY.Config.WebInfo.Instance.FirmOrderAgencyFee); int? orderId = string.IsNullOrEmpty(Request["id"]) ? null : MyConvert.ConvertToInt32(Request["id"]); if (!orderId.HasValue || !commission.HasValue) { Response.Write("-2"); return; } else { } Response.Write(_eC_OrderBasicBLL.AcceptOrder(orderId.Value, commission.Value) ? "1" : "0"); } /// /// 批量受理订单 /// public void AcceptAll() { Response.Clear(); PayAbout payAbout = new PayAbout(); payAbout.LoadNewestPaymentAccount(true); double? commission = MyConvert.ConvertToDouble(CY.Config.WebInfo.Instance.FirmOrderAgencyFee); string orderIds = string.Empty; ; if (Request["ids"] != null) { orderIds = Request["ids"].ToString(); } if (string.IsNullOrEmpty(orderIds) || !commission.HasValue) { Response.Write("-2"); return; } else { } Response.Write(_eC_OrderBasicBLL.AcceptOrderAll(orderIds, commission.Value) ? "1" : "0"); } /// /// 改变订单状态(暂时不启用) /// private void ChangeOrderState() { Response.Clear(); string idsStr = Request["ids"]; string stateIdStr = Request["stateId"]; string remark = string.Format("{0}", Request["remark"]); int? stateId = string.IsNullOrEmpty(stateIdStr) ? null : MyConvert.ConvertToInt32(stateIdStr); if (string.IsNullOrEmpty(idsStr) || !stateId.HasValue) { Response.Write("-2"); return; } else { } string[] ids = idsStr.Split(','); int i = -1; int? tempId = null; List operaters = new List(); while (++i < ids.Length) { tempId = string.IsNullOrEmpty(ids[i]) ? null : MyConvert.ConvertToInt32(ids[i]); if (!tempId.HasValue) { operaters = null; break; } else { } operaters.Add(new EC_OrderOperate() { OrderId = tempId.Value, Operator = CurrentUser.ShortName, OperateType = stateId.Value, Remark = remark }); } if (null == operaters) { Response.Write("-2"); return; } else { } Response.Write(_eC_OrderBasicBLL.UpdateOrderState(operaters.ToArray()) ? "1" : "0"); } /// /// 卖家退单 /// public void RetireOrderBySeller() { string orderidStr = Request["orderid"]; string tovalueStr = Request["tovalue"]; int orderId = orderidStr.ToInt32().Value; decimal retireMony = tovalueStr.ToDecimal2().Value; string operatorName = CurrentUser.ShortName; Response.Write(_eC_OrderBasicBLL.RetireOrderBySeller(orderId, retireMony, operatorName)); } /// /// 请求延期 /// /// 请求类型 private void Delay(int typeId) { Response.Clear(); string receiverStr = Request["receiver"]; string orderidStr = Request["orderid"]; string tovalueStr = Request["tovalue"]; if (string.IsNullOrEmpty(receiverStr) || string.IsNullOrEmpty(orderidStr) || string.IsNullOrEmpty(tovalueStr)) { Response.Write(0); return; } else { } int? orderid = MyConvert.ConvertToInt32(orderidStr); int? tovalue = MyConvert.ConvertToInt32(tovalueStr); Guid receiver = MyConvert.ConvertToGuid(receiverStr); if (Guid.Empty == receiver || !orderid.HasValue || !tovalue.HasValue) { Response.Write(0); return; } else { } EC_OrderDialogue _eC_OrderDialogue = new EC_OrderDialogue(); _eC_OrderDialogue.ReceiverId = receiver; _eC_OrderDialogue.TargetOrder = orderid; _eC_OrderDialogue.TargetValue = tovalue; _eC_OrderDialogue.DialogueTypeId = typeId; _eC_OrderDialogue.InitiatorId = CurrentUser.MemberId; _eC_OrderDialogue.DialogueContent = string.Format("{0}", Request["dialoguecontent"]); //开始请求 Response.Write(_eC_OrderBasicBLL.OrderPropertyChangeRequest(_eC_OrderDialogue)); } /// /// 答复清单请求 /// private void RequestReply() { Response.Clear(); string ridStr = Request["did"]; string isAllowStr = Request["isAllow"]; Guid rid = MyConvert.ConvertToGuid(ridStr); bool? isAllow = Convert.ToBoolean(isAllowStr); if (Guid.Empty == rid || !isAllow.HasValue) { Response.Write(0); return; } else { } Response.Write(_eC_OrderBasicBLL.OrderPropertyChangeReply(rid, CurrentUser.MemberId, isAllow.Value)); } private void ToBatchRemove() { string orderidStr = Request["orderid"]; string tovalueStr = Request["tovalue"]; int orderId = orderidStr.ToInt32().Value; decimal retireMony = tovalueStr.ToDecimal2().Value; string operatorName = CurrentUser.ShortName; Response.Write(_eC_OrderBasicBLL.RetireOrderBySeller(orderId, retireMony, operatorName)); } /// /// 默认执行方法 /// private void Page_Load_Default() { // UCPager1.AspNetPager.PageChanged += AspNetPager_PageChanged; btn_Search.Click += btn_Search_Click; txtCommission.Value = CY.Config.WebInfo.Instance.FirmOrderAgencyFee; List dialogues = _eC_OrderBasicBLL.SelectPropertyChangeRequest(CurrentUser.MemberId) as List; if (!IsPostBack && !IsCallback) { Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();//字典业务逻辑操作类对象 SysInquiry_PrintingTypeBLL _sysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL();//印刷业务类型业务逻辑操作类对象 this.selPrintTypes.DataSource = _sysInquiry_PrintingTypeBLL.SelectUsedModles(); this.selPrintTypes.DataBind(); this.selPrintTypes.Items.Insert(0, new ListItem("全部", "")); this.selPrintTypes.Items.Add(new ListItem("其他", "-1")); this.selOrderTypes.DataSource = _sys_DictionaryBLL.GetDataByType("EC_订单类型"); this.selOrderTypes.DataBind(); this.selOrderTypes.Items.Insert(0, new ListItem("全部", "")); this.selPayStates.DataSource = _sys_DictionaryBLL.GetDataByType("EC_订单支付状态"); this.selPayStates.DataBind(); this.selPayStates.Items.Insert(0, new ListItem("全部", "")); this.selOrderStates.DataSource = _sys_DictionaryBLL.GetDataByType("EC_订单状态").Where(p => p.MeanValue.Value != -5 && p.MeanValue.Value != -4); this.selOrderStates.DataBind(); this.selOrderStates.Items.Insert(0, new ListItem("全部", "")); this.selCustormerLevels.DataSource = _sys_DictionaryBLL.GetDataByType("客户重要程度"); this.selCustormerLevels.DataBind(); this.selCustormerLevels.Items.Insert(0, new ListItem("全部", "")); this.selPayType.DataSource = _sys_DictionaryBLL.GetDataByType("EC_支付方式"); this.selPayType.DataTextField = "Name"; this.selPayType.DataValueField = "MeanValue"; this.selPayType.DataBind(); this.selPayType.Items.Insert(0, new ListItem("全部", "")); this.selCustormerManager.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, true); this.selCustormerManager.DataTextField = "Name"; this.selCustormerManager.DataValueField = "Keyid"; this.selCustormerManager.DataBind(); this.selCustormerManager.Items.Insert(0, new ListItem("全部", "")); //this.selCustormerManager.Items.Insert(1, new ListItem(CurrentUser.ShortName, CurrentUser.ShortName)); this.selBusinessManager.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false); this.selBusinessManager.DataTextField = "Name"; this.selBusinessManager.DataValueField = "Keyid"; this.selBusinessManager.DataBind(); this.selBusinessManager.Items.Insert(0, new ListItem("全部", "")); //this.selBusinessManager.Items.Insert(1, new ListItem(CurrentUser.ShortName, CurrentUser.ShortName)); this.txtBeginData.Value = DateTime.Now.AddDays(-14).ToString("yyyy-MM-dd"); this.txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd"); //初次数据加载 btn_Search_Click(btn_Search, new EventArgs()); } } #region 查询 /// /// 搜索按钮点击事件 /// /// /// private void btn_Search_Click(object sender, EventArgs e) { /* if (this.txtCustormerName.Value.Trim() == "") { Response.Write("客户名称不能为空,请输入客户名称再查询……"); return; }*/ Dictionary searchParam = new Dictionary(); SetParamValue(searchParam, 1, CurrentUser.MemberId); SetParamValue(searchParam, 2, this.txtOrderId.Value.Trim()); SetParamValue(searchParam, 3, this.txtCustormerName.Value.Trim()); SetParamValue(searchParam, 4, this.txtBeginData.Value.Trim()); SetParamValue(searchParam, 5, this.txtEndDate.Value.Trim()); SetParamValue(searchParam, 6, this.selPrintTypes.Value); SetParamValue(searchParam, 7, this.selOrderTypes.Value); SetParamValue(searchParam, 8, this.selOrderStates.Value); SetParamValue(searchParam, 9, this.selPayStates.Value); SetParamValue(searchParam, 10, this.txtCreaterName.Value.Trim()); SetParamValue(searchParam, 11, this.selCustormerLevels.Value); SetParamValue(searchParam, 12, this.selCustormerManager.Value); SetParamValue(searchParam, 13, this.selBusinessManager.Value); SetParamValue(searchParam, 14, this.selPayType.SelectedValue); SetParamValue(searchParam, 15, this.selReturnvisit.SelectedValue); SetParamValue(searchParam, 16, this.selAppraise.SelectedValue); SetParamValue(searchParam, 18, (CurrentUser.StaffId > 0 ? 1 : 0)); SetParamValue(searchParam, 19, CurrentUser.TrueMemberId); SetParamValue(searchParam, 20, CurrentUser.StaffId); SetParamValue(searchParam, 21, CurrentUser.TrueName); SearchParam = searchParam; /// UCPager1.AspNetPager.CurrentPageIndex = 1;//重置页数 //再次查询 // AspNetPager_PageChanged(UCPager1.AspNetPager, new EventArgs()); Infrastructure.Query.Pagination pagination = new Infrastructure.Query.Pagination() { PageSize = 100,// UCPager1.AspNetPager.PageSize, PageIndex = 1// UCPager1.AspNetPager.CurrentPageIndex }; IEnumerable result = _eC_OrderBasicBLL.SelectModelPage_Seller(pagination, SearchParam);//.Where(x=>x.Quchudingdan == 2); rptData.DataSource = result; rptData.DataBind(); } /// /// 设置查询参数方法 /// /// 设置目标 /// 键 /// 值 private static void SetParamValue(Dictionary target, int key, object value) { if (string.IsNullOrEmpty(string.Format("{0}", value))) return; else { } if (target.ContainsKey(key)) { target[key] = value; } else { target.Add(key, value); } } /// /// 分页事件 /// /// /// private void AspNetPager_PageChanged(object sender, EventArgs e) { //UCPager1.AspNetPager.PageSize = 3; Infrastructure.Query.Pagination pagination = new Infrastructure.Query.Pagination() { PageSize = 1000,// UCPager1.AspNetPager.PageSize, PageIndex = 1// UCPager1.AspNetPager.CurrentPageIndex }; IEnumerable result = _eC_OrderBasicBLL.SelectModelPage_Seller(pagination, SearchParam); rptData.DataSource = result; rptData.DataBind(); //UCPager1.AspNetPager.RecordCount = pagination.RecordCount; } /// /// 查询参数 /// private Dictionary SearchParam { get { return ViewState["SearchParam"] as Dictionary; } set { ViewState["SearchParam"] = value; } } /// /// 是否可以操作 /// /// /// /// /// public bool IsCanOpearte(object keyidObj, object orderStateObj, object outIdObj, object opTypeObj) { bool isCan = false; int keyid = (int)keyidObj; int orderState = (int)orderStateObj; string opType = (string)opTypeObj; int outId = (int)outIdObj; if (orderState == -2) { return false; } if (opType == "回访" || opType == "评价" || opType == "投诉") { if (orderState == 1) { isCan = false; } else { isCan = true; } } else { if (outId > 0) { return false; } if (orderState == 0) { isCan = false; } else if (orderState == -1) { if (opType != "送货") { isCan = false; } else { isCan = true; } } else { if (opType == "受理") { if (orderState == 1) { isCan = true; } } else { if (orderState == 1) { isCan = false; } else { if (opType == "撤单") { if (orderState == 4 || orderState == 5) { isCan = false; } else { isCan = true; } } else { isCan = true; } } } } } return isCan; } /// /// 是否已经操作 /// /// /// /// /// public bool IsOpearted(object keyidObj, object orderStateObj, object opTypeObj) { int keyid = (int)keyidObj; int orderState = (int)orderStateObj; string opType = (string)opTypeObj; return _eC_OrderBasicBLL.IsOpearted(keyid, orderState, opType); } /// /// 批量去除订单 /// public void AcceptAll2() { Response.Clear(); string ids = string.Empty; if (Request["ids"] != null) { ids = Request["ids"].ToString(); } string[] idsArray = ids.Split(','); using (TransactionScope scope = new TransactionScope()) { if (idsArray != null && idsArray.Length > 0) { for (int i = 0; i < idsArray.Length; i++) { bool result = true; EC_OrderExtend model = new EC_OrderExtend(); model.Keyid = idsArray[i].ToInt32(); model.QuchudingdanCreater = CurrentUser.TrueMemberId; model.QuchudingdanTime = DateTime.Now; model.Quchudingdan = 1; result = _eC_OrderBLL.OldUpdateQuchudingdan(model); if (!result) { //Page_Load_Default(); Response.Write("-2"); return; } } } scope.Complete(); } // Page_Load_Default(); Response.Write("1"); } /// /// 批量开票申请 /// public void AcceptAll3() { Response.Clear(); string ids = string.Empty; if (Request["ids"] != null) { ids = Request["ids"].ToString(); } string[] idsArray = ids.Split(','); if (idsArray != null && idsArray.Length > 0) { EC_OrderBasic eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(idsArray[0].ToInt32().Value); OA_CorporateClients oA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, eC_OrderBasic.BuyerId); using (TransactionScope scope = new TransactionScope()) { string ssss = DateTime.Now.ToString("yyyyMMdd"); string SellerOrderId = ssss + 1.ToString("000"); string maxSellerOrderId = _oA_KaipiaoshenqingBLL.GetModelByformid(CurrentUser.MemberId).Where(x => x.SellerOrderId.Contains(ssss)).Max(x => x.SellerOrderId); if (!string.IsNullOrWhiteSpace(maxSellerOrderId)) { string aaaaaaaaaaaa = maxSellerOrderId.Substring(maxSellerOrderId.Length - 3, 3); SellerOrderId = ssss + (aaaaaaaaaaaa.ToInt32().Value + 1).ToString("000"); } OA_Kaipiaoshenqing oA_DeliverPlan = new OA_Kaipiaoshenqing(); oA_DeliverPlan.Keyid = Guid.NewGuid(); oA_DeliverPlan.FirmId = CurrentUser.MemberId; oA_DeliverPlan.BuyerId = eC_OrderBasic.BuyerId; oA_DeliverPlan.Kaipiaoshenqing = 1; oA_DeliverPlan.Kehuqianshou = 1; oA_DeliverPlan.SellerOrderId = SellerOrderId; oA_DeliverPlan.KehuqianshouTime = null; oA_DeliverPlan.KehuqianshouCreater = null; oA_DeliverPlan.KaipiaoquerenTime = null; oA_DeliverPlan.KaipiaoquerenCreater = null; oA_DeliverPlan.BusinessManagerId = oA_CorporateClients.BusinessManagerId ?? 0; oA_DeliverPlan.Creater = CurrentUser.TrueMemberId; oA_DeliverPlan.CreateTime = DateTime.Now; oA_DeliverPlan.Updater = CurrentUser.TrueMemberId; oA_DeliverPlan.LastUpdateTime = DateTime.Now; _oA_KaipiaoshenqingBLL.InsertModel(oA_DeliverPlan); DateTime kaipiaoshenqing = DateTime.Now; for (int i = 0; i < idsArray.Length; i++) { bool result = true; EC_OrderExtend model = new EC_OrderExtend(); model.Keyid = idsArray[i].ToInt32(); model.KaipiaoshenqingCreater = CurrentUser.TrueMemberId; model.KaipiaoshenqingTime = kaipiaoshenqing; model.Kaipiaoshenqing = 1; model.KaipiaoshenqingId = oA_DeliverPlan.Keyid; result = _eC_OrderBLL.OldUpdateKaipiaoshenqing(model); if (!result) { //Page_Load_Default(); Response.Write("-2"); return; } } scope.Complete(); } } // Page_Load_Default(); Response.Write("1"); } #endregion } }