/// <summary>
        /// 删除款项
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="request"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool DeleteSaleOrderReceive(UserModel userModel, SaleReceive request, out string msg)
        {
            var m = Da.Get <SaleReceive>(request.SaleReceiveId);

            if (m == null)
            {
                msg = "订单不存在,操作失败";
                return(false);
            }

            var order = Da.Get <SaleOrder>(m.SaleOrderId);
            var b1    = CheckAuthOrder(userModel, order, out msg);

            if (!b1)
            {
                return(false);
            }

            if (order.Status == (int)SaleOrderStatusEnum.Draft || order.Status == (int)SaleOrderStatusEnum.ShipedPay)
            {
                msg = "删除失败";
                return(false);
            }

            return(Da.Delete(m));
        }
        /// <summary>
        /// 添加款项
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="request"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool AddSaleOrderReceive(UserModel userModel, SaleReceive request, out string msg)
        {
            var order = Da.Get <SaleOrder>(request.SaleOrderId);
            var b1    = CheckAuthOrder(userModel, order, out msg);

            if (!b1)
            {
                return(false);
            }

            if (order.Status == (int)SaleOrderStatusEnum.Draft || order.Status == (int)SaleOrderStatusEnum.ShipedPay)
            {
                msg = "添加失败";
                return(false);
            }

            var currency = Da.Get <Currency>(request.CurrencyId);
            var b2       = CheckAuthCurrency(userModel, currency, out msg);

            if (!b2)
            {
                return(false);
            }

            var accout = Da.Get <Account>(request.AccountId);
            var b3     = CheckAuthAccount(userModel, accout, out msg);

            if (!b3)
            {
                return(false);
            }

            var m = new SaleReceive()
            {
                SaleReceiveId  = SeqGuid.NewGuid(),
                SaleOrderId    = order.SaleOrderId,
                AccountInfo    = $"{accout.AccountBank}[{accout.AccountNumber}]",
                Amount         = request.Amount,
                CurrencySymbol = currency.CurrencySymbol,
                CurrencyRate   = currency.CurrencyRate,
                Remark         = null,
                CreateName     = userModel.UserNickName,
                CreateDate     = DateTime.Now,
            };

            Da.Add <Guid, SaleReceive>(m);
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="model"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public virtual bool DeleteSaleReceive(UserModel userModel, SaleReceive model, out string msg)
        {
            var m = Da.Get <SaleReceive>(model.SaleReceiveId);

            if (m == null || m.SaleOrderId != model.SaleOrderId)
            {
                msg = "记录不存在";
                return(false);
            }

            var order = Da.Get <SaleOrder>(m.SaleOrderId);
            var b1    = CheckAuthOrder(userModel, order, out msg);

            if (!b1)
            {
                return(false);
            }

            var status = new List <int>()
            {
                (int)SaleOrderStatusEnum.SubmitUnpay,
                (int)SaleOrderStatusEnum.SubmitAfterPay,
                (int)SaleOrderStatusEnum.StockedUnpay,
                (int)SaleOrderStatusEnum.StockedAfterPay,
                (int)SaleOrderStatusEnum.ShipedAfterPay,
            };

            if (!status.Exists(p => p == order.Status))
            {
                msg = "订单已锁定,操作失败";
                return(false);
            }

            msg = null;
            return(Da.Delete(m));
        }
Exemple #4
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="model"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public virtual bool UpdateSaleReceive(UserModel userModel, SaleReceive model, out string msg)
        {
            var m = Da.Get <SaleReceive>(model.SaleReceiveId);

            if (m == null)
            {
                msg = "收款记录已不存在";
                return(false);
            }

            var order = Da.Get <SaleOrder>(m.SaleOrderId);
            var b1    = CheckAuthOrder(userModel, order, out msg);

            if (!b1)
            {
                return(false);
            }

            var status = new List <int>()
            {
                (int)SaleOrderStatusEnum.SubmitUnpay,
                (int)SaleOrderStatusEnum.SubmitAfterPay,
                (int)SaleOrderStatusEnum.StockedUnpay,
                (int)SaleOrderStatusEnum.StockedAfterPay,
                (int)SaleOrderStatusEnum.ShipedAfterPay,
            };

            if (!status.Exists(p => p == order.Status))
            {
                msg = "订单已锁定,操作失败";
                return(false);
            }

            var account = Da.Get <Account>(model.AccountId);
            var b2      = CheckAuthAccount(userModel, account, out msg);

            if (!b2)
            {
                return(false);
            }

            var currency = Da.Get <Currency>(model.CurrencyId);
            var b3       = CheckAuthCurrency(userModel, currency, out msg);

            if (!b3)
            {
                return(false);
            }

            m.AccountInfo = $"{account.AccountBank}({account.AccountNumber})";
            m.Amount      = model.Amount;

            m.CurrencySymbol = currency.CurrencySymbol;
            m.CurrencyRate   = currency.CurrencyRate;

            m.Amount            = model.Amount;
            m.TranFee           = model.TranFee;
            m.TransactionNumber = model.TransactionNumber;
            m.Remark            = model.Remark;

            m.CreateName = userModel.UserNickName;
            m.CreateDate = DateTime.Now;
            m.CurrencyId = model.CurrencyId;
            m.AccountId  = model.AccountId;

            return(Da.Update(m));
        }
Exemple #5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="model"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public virtual bool AddSaleReceive(UserModel userModel, SaleReceive model, out string msg)
        {
            var order = Da.Get <SaleOrder>(model.SaleOrderId);
            var b1    = CheckAuthOrder(userModel, order, out msg);

            if (!b1)
            {
                return(false);
            }

            var status = new List <int>()
            {
                (int)SaleOrderStatusEnum.SubmitUnpay,
                (int)SaleOrderStatusEnum.SubmitAfterPay,
                (int)SaleOrderStatusEnum.StockedUnpay,
                (int)SaleOrderStatusEnum.StockedAfterPay,
                (int)SaleOrderStatusEnum.ShipedAfterPay,
            };

            if (!status.Exists(p => p == order.Status))
            {
                msg = "订单已锁定,操作失败";
                return(false);
            }

            var account = Da.Get <Account>(model.AccountId);
            var b2      = CheckAuthAccount(userModel, account, out msg);

            if (!b2)
            {
                return(false);
            }

            var currency = Da.Get <Currency>(model.CurrencyId);
            var b3       = CheckAuthCurrency(userModel, currency, out msg);

            if (!b3)
            {
                return(false);
            }

            var m = new SaleReceive()
            {
                SaleReceiveId     = SeqGuid.NewGuid(),
                SaleOrderId       = model.SaleOrderId,
                AccountInfo       = $"{account.AccountBank}({account.AccountNumber})",
                Amount            = model.Amount,
                TranFee           = model.TranFee,
                CurrencySymbol    = currency.CurrencySymbol,
                CurrencyRate      = currency.CurrencyRate,
                TransactionNumber = model.TransactionNumber,
                Remark            = model.Remark,
                CreateName        = userModel.UserNickName,
                CreateDate        = DateTime.Now,
                AccountId         = account.AccountId,
                CurrencyId        = currency.CurrencyId,
            };

            Da.Add <Guid, SaleReceive>(m);
            return(true);
        }
        public IResponseResult DeleteSaleReceive(SaleReceive model)
        {
            var result = Biz.DeleteSaleReceive(UserModel, model, out var msg);

            return(ReturnResult(result, msg));
        }