Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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");
        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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;
        }