Example #1
0
        public SimpleJson ToJSon(ISession session)
        {
            SimpleJson json = new SimpleJson()
                              .Add("orderNumber", this.OrderNumber)
                              .Add("saleOrder", this.SaleOrderNumber)
                              .Add("memberId", this.MemberID);
            string memberName = " ";

            if (this.MemberID > 0)
            {
                Magic.Basis.Member member = Magic.Basis.Member.Retrieve(session, this.MemberID);
                if (member != null)
                {
                    memberName = member.Name;
                }
            }
            json.Add("member", memberName);
            json.Add("contact", this.Contact)
            .Add("phone", this.Phone)
            .Add("mobile", this.Mobile)
            .Add("address", this.Address)
            .Add("district", this.Province + " " + this.City)
            .Add("shippingNumber", this.ShippingNumber)
            .Add("isInvoice", this.IsInvoice)
            .Add("invoice", Cast.String(this.InvoiceNumber, "").Trim())
            .Add("packageWeight", this.PackageWeight)
            .Add("logistics", this.LogisticsID)
            .Add("packageCount", this.PackageCount <= 0 ? 1 : this.PackageCount);
            string paymentMethod = " ";

            if (this.PaymentMethod > 0)
            {
                CRM.PaymentMethod pm = CRM.PaymentMethod.Retrieve(session, this.PaymentMethod);
                if (pm != null)
                {
                    paymentMethod = pm.Name;
                }
            }
            json.Add("paymentMethod", paymentMethod);
            string deliverType = " ";

            if (this.DeliveryType > 0)
            {
                CRM.DeliverType dt = CRM.DeliverType.Retrieve(session, this.DeliveryType);
                if (dt != null)
                {
                    deliverType = dt.Name;
                }
            }
            json.Add("deliverType", deliverType);
            string logisName = " ";

            if (this.LogisticsID > 0)
            {
                Logistics logis = Logistics.Retrieve(session, this.LogisticsID);
                if (logis != null)
                {
                    logisName = logis.ShortName;
                }
            }
            json.Add("logisticsName", logisName);
            string packageType = " ";

            if (this.PackageType > 0)
            {
                CRM.PackageType pt = CRM.PackageType.Retrieve(session, this.PackageType);
                if (pt != null)
                {
                    packageType = pt.Name;
                }
            }
            json.Add("packageType", packageType)
            .Add("note", string.IsNullOrEmpty(this.Remark) ? " " : this.Remark.Replace("</br>", " "));
            json.Add("packageUser", string.IsNullOrEmpty(this.PackagePerson) ? " " : this.PackagePerson);
            return(json);
        }
Example #2
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;
        }