public void AddLine(ISession session, CRMSN sn) { if (sn == null) { return; } if (sn.Status != CRMSNStatus.Checked && sn.Status != CRMSNStatus.Packaged) { throw new Exception("只有已经核货、包装的发货单才能进行交接"); } if (this.LogisticCompID != sn.LogisticsID) { throw new Exception("发货单包装时选择的物流公司与交接单的物流公司不同"); } IList <ICHead> icHeads = session.CreateObjectQuery(@" select 1 from ICHead h inner join ICLine l on h.OrderNumber=l.OrderNumber where l.RefOrderNumber=?snno ") .Attach(typeof(ICHead)).Attach(typeof(ICLine)) .And(Exp.In("h.Status", InterchangeStatus.New, InterchangeStatus.Release, InterchangeStatus.Open)) .SetValue("?snno", sn.OrderNumber, "l.RefOrderNumber") .List <ICHead>(); if (icHeads != null && icHeads.Count > 0) { throw new Exception("发货单" + sn.OrderNumber + "已经加入到交接单" + icHeads[0].OrderNumber + "中了"); } ICLine line = new ICLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.OrderTypeCode = " "; line.RefOrderNumber = sn.OrderNumber; line.Create(session); }
public static SimpleJson DeliverOrder4Package(ISession session, string orderNumber) { CRMSN shippingNotice = CRMSN.Retrieve(session, orderNumber); if (shippingNotice == null) { return(new SimpleJson().HandleError(string.Format("发货单{0}不存在", orderNumber))); } if (shippingNotice.Status != CRMSNStatus.Checked) { throw new Exception("发货单" + shippingNotice.OrderNumber + "没有核货或者已经包装完毕,无法执行包装作业"); } return(shippingNotice.ToJSon(session)); }
public static void PackageFinish(ISession session, string orderNumber) { CRMSN head = CRMSN.Retrieve(session, orderNumber); if (head == null) { throw new Exception("发货单" + orderNumber + "不存在"); } if (head.Status != CRMSNStatus.Checked) { throw new Exception("发货单" + orderNumber + "没有核货或者已经包装完毕,无法执行包装作业"); } head.Status = CRMSNStatus.Packaged; head.PackageDate = DateTime.Now; head.PackagePerson = Security.SecuritySession.CurrentUser == null ? " " : Security.SecuritySession.CurrentUser.FullName; head.Update(session, "Status", "PackageDate", "PackagePerson"); }
public static SimpleJson DeliverOrder4Check(ISession session, string orderNumber) { CRMSN shippingNotice = CRMSN.Retrieve(session, orderNumber); if (shippingNotice == null) { return(new SimpleJson().HandleError(string.Format("发货单{0}不存在", orderNumber))); } if (shippingNotice.Status != CRMSNStatus.Distributing) { return(new SimpleJson().HandleError(string.Format("发货单{0}不是已打印状态,无法进行核货作业", shippingNotice.OrderNumber))); } SimpleJson json = shippingNotice.ToJSon(session); //是否需要过滤掉不必要核货的发货明细? DataSet ds = session.CreateObjectQuery(@" select s.BarCode as SKU,m.ItemCode as ItemCode,m.ItemName as ItemName ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode ,sum(l.Quantity) as Quantity from CRMSNLine l inner join ItemSpec s on l.SKUID=s.SKUID inner join ItemMaster m on m.ItemID=s.ItemID left join ItemColor color on color.ColorCode=s.ColorCode group by s.BarCode,m.ItemCode,m.ItemName,s.ColorCode,color.ColorText,s.SizeCode order by s.BarCode") .Attach(typeof(CRMSNLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)) .Attach(typeof(ItemColor)) .Where(Exp.Eq("l.SNID", shippingNotice.ID)) .DataSet(); IList <SimpleJson> lineJson = new List <SimpleJson>(ds.Tables[0].Rows.Count); foreach (DataRow row in ds.Tables[0].Rows) { lineJson.Add(new SimpleJson() .Add("sku", row["SKU"]) .Add("itemCode", row["ItemCode"]) .Add("color", Cast.String(row["ColorCode"]) + " " + Cast.String(row["ColorText"])) .Add("size", row["SizeCode"]) .Add("itemName", row["ItemName"]) .Add("qty", row["Quantity"])); } json.Add("lines", lineJson); return(json); }
public static void PackageSave(ISession session, string orderNumber, decimal packageWeight, string shippingNumber, int logisticId, string invoiceNumber, int packageCount) { CRMSN head = CRMSN.Retrieve(session, orderNumber); if (head == null) { throw new Exception("发货单" + orderNumber + "不存在"); } if (head.Status != CRMSNStatus.Checked) { throw new Exception("发货单" + orderNumber + "没有核货或者已经包装完毕,无法执行包装作业"); } IList <RestrictLogis2Member> restricts = session.CreateEntityQuery <RestrictLogis2Member>() .Where(Exp.Eq("MemberId", head.MemberID)) .List <RestrictLogis2Member>(); bool isInRestrict = false; string logisNames = ""; foreach (RestrictLogis2Member r in restricts) { Logistics logis = Logistics.Retrieve(session, r.LogisId); if (logis != null) { logisNames = logisNames + logis.ShortName + ", "; } if (r.LogisId == logisticId) { isInRestrict = true; } } if (restricts != null && restricts.Count > 0 && !isInRestrict) { throw new Exception("系统设置该会员只能通过\"" + logisNames.Substring(0, logisNames.Length - 2) + "\"发货"); } head.PackageWeight = packageWeight; head.ShippingNumber = shippingNumber; head.LogisticsID = logisticId; head.InvoiceNumber = invoiceNumber; head.PackageCount = packageCount; head.Update(session, "PackageWeight", "ShippingNumber", "LogisticsID", "InvoiceNumber", "PackageCount"); }
public void AddLines(ISession session, string[] sns) { if (sns == null || sns.Length <= 0) { return; } foreach (string s in sns) { if (string.IsNullOrEmpty(s) || s.Length <= 0) { continue; } CRMSN sn = CRMSN.Retrieve(session, s); if (sn == null) { throw new Exception("发货单" + s + "不存在"); } this.AddLine(session, sn); } }
public static SimpleJson AddLine(ISession session, string icNumber, string snNumber) { if (string.IsNullOrEmpty(icNumber) || string.IsNullOrEmpty(snNumber)) { throw new Exception("无效参数"); } ICHead head = ICHead.Retrieve(session, icNumber); if (head == null) { throw new Exception("交接单" + icNumber + "不存在"); } CRMSN sn = CRMSN.Retrieve(session, snNumber); if (sn == null) { throw new Exception("发货单" + snNumber + "不存在"); } head.AddLine(session, sn); return(sn.ToJSon(session)); }
public void AutoGenerateDetail(ISession session) { if (this.Status != InterchangeStatus.New) { throw new Exception("发货单不是新建状态,无法修改"); } if (this.LogisticCompID <= 0) { throw new Exception("交接单上的物流公司无效"); } IList <CRMSN> sns = CRMSN.InterchangableList(session, this.LogisticCompID); foreach (CRMSN sn in sns) { ICLine line = new ICLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.OrderTypeCode = " "; line.RefOrderNumber = sn.OrderNumber; line.Create(session); } }
public static void CheckFinish(ISession session, string orderNumber) { if (string.IsNullOrEmpty(orderNumber) || orderNumber.Trim().Length <= 0) { throw new Exception("发货单号码为空,无法执行该操作"); } CRMSN head = CRMSN.Retrieve(session, orderNumber); if (head == null) { throw new Exception("发货单" + orderNumber + "不存在"); } if (head.Status != CRMSNStatus.Distributing) { return; } head.Status = CRMSNStatus.Checked; User user = User.Retrieve(session, Security.SecuritySession.CurrentUser.UserId); head.CheckPerson = user == null ? " " : user.FullName; head.CheckDate = DateTime.Now; head.Update(session, "Status", "CheckPerson", "CheckDate"); if (head._lines == null || head._lines.Count <= 0) { head._lines = session.CreateEntityQuery <CRMSNLine>() .Where(Exp.Eq("SNID", head.ID)) .OrderBy("SKUID").OrderBy("ID") .List <CRMSNLine>(); } foreach (CRMSNLine line in head._lines) { line.Status = CRMSNLineStatus.Checked; line.Update(session, "Status"); } head.WHTransactionDo(session); }
public void AddLine(ISession session, CRMSN sn) { if (sn == null) return; if (sn.Status != CRMSNStatus.Checked && sn.Status != CRMSNStatus.Packaged) throw new Exception("ֻ���Ѿ��˻�����װ�ķ��������ܽ��н���"); if (this.LogisticCompID != sn.LogisticsID) throw new Exception("��������װʱѡ���������˾�뽻�ӵ���������˾��ͬ"); IList<ICHead> icHeads = session.CreateObjectQuery(@" select 1 from ICHead h inner join ICLine l on h.OrderNumber=l.OrderNumber where l.RefOrderNumber=?snno ") .Attach(typeof(ICHead)).Attach(typeof(ICLine)) .And(Exp.In("h.Status", InterchangeStatus.New, InterchangeStatus.Release, InterchangeStatus.Open)) .SetValue("?snno", sn.OrderNumber, "l.RefOrderNumber") .List<ICHead>(); if (icHeads != null && icHeads.Count > 0) throw new Exception("������" + sn.OrderNumber + "�Ѿ����뵽���ӵ�" + icHeads[0].OrderNumber + "����"); ICLine line = new ICLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.OrderTypeCode = " "; line.RefOrderNumber = sn.OrderNumber; line.Create(session); }
public void LogisReturn(ISession session, string locationCode, string snNumber, int reasonId, bool isMalicious, bool hasTransported, string note, int createUser) { if (string.IsNullOrEmpty(snNumber) || snNumber.Trim().Length <= 0) { throw new Exception("必须填写发货单号码"); } CRMSN sn = CRMSN.Retrieve(session, snNumber.Trim()); if (sn == null) { throw new Exception("发货单" + snNumber + "不存在"); } if (sn.Status == CRMSNStatus.Return) { throw new Exception("发货单" + sn.OrderNumber + "已经退货"); } if (sn.Status == CRMSNStatus.PartExchange) { throw new Exception("发货单" + sn.OrderNumber + "已经换货"); } if (sn.Status != CRMSNStatus.Interchanged) { throw new Exception("发货单" + snNumber + "未完成,无法退货"); } if (!string.IsNullOrEmpty(this.OrderNumber) && this.OrderNumber.Trim().Length > 0 && !string.IsNullOrEmpty(this.RefOrderNumber) && this.RefOrderNumber.Trim().Length > 0 && this.RefOrderNumber != snNumber) { //发货单号码改变,检查是否已经有明细存在,如果已经有明细了则不允许删除 if (session.CreateEntityQuery <ReturnLine>().Where(Exp.Eq("OrderNumber", this.OrderNumber)).Count() > 0) { throw new Exception("退货单" + this.OrderNumber + "已经存在退货明细,无法再改变发货单号码"); } } this.RefOrderNumber = sn.OrderNumber; this.RefOrderID = sn.ID; this.OrginalOrderNumber = sn.SaleOrderNumber; this.MemberID = sn.MemberID; if (sn.MemberID > 0) { Magic.Basis.Member member = Magic.Basis.Member.Retrieve(session, sn.MemberID); if (member != null) { this.MemberName = member.Name; } } this.LogisticsID = sn.LogisticsID; if (this.LogisticsID > 0) { Magic.Basis.Logistics logis = Magic.Basis.Logistics.Retrieve(session, this.LogisticsID); this.LogisticsName = logis.ShortName; } this.LocationCode = locationCode; this.IsMalicious = isMalicious; this.HasTransported = hasTransported; this.Note = note; this.ReasonID = reasonId; if (reasonId > 0) { Magic.Basis.ReturnReason reason = Magic.Basis.ReturnReason.Retrieve(session, reasonId); if (reason != null) { this.ReasonText = reason.ReasonText; } } this.OrderTypeCode = ORDER_TYPE_LOGISTICS_RTN; this.CreateUser = createUser; this.IsAutoMatch = true; }