Example #1
0
        /// <summary>
        /// 门店提货或者转快递,插入收款明细
        /// </summary>
        /// <param name="orderID">订单号</param>
        /// <param name="item">收款明细</param>
        /// <param name="isThrowException">是否抛出异常</param>
        /// <returns></returns>
        ///<remarks>2013-07-08 朱成果 创建</remarks>
        public void InsertOrderReceiptVoucher(int orderID, FnReceiptVoucherItem item, bool isThrowException = true)
        {
            //收款单
            var order  = SoOrderBo.Instance.GetEntity(orderID);
            var entity = Hyt.DataAccess.Finance.IFnReceiptVoucherDao.Instance.GetEntity(sourceFromOrder, orderID);

            if (entity == null) //不存在收款单创建一条记录
            {
                entity = CreateReceiptVoucherByOrder(order);
            }
            item.ReceiptVoucherSysNo = entity.SysNo;//收款单编号
            item.TransactionSysNo    = entity.TransactionSysNo;
            item.Status            = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款单明细状态.效;
            entity.ReceivedAmount += item.Amount;
            if (entity.ReceivedAmount > entity.IncomeAmount)
            {
                Hyt.BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台, "收款金额超过了应收款金额", LogStatus.系统日志目标类型.收款单明细, item.SysNo, item.CreatedBy);
                //在线付款不抛出异常
                if (isThrowException)
                {
                    throw new Exception("收款金额超过了应收款金额");
                }
            }
            if ((int)entity.ReceivedAmount >= (int)entity.IncomeAmount)                                        //更新订单的支付状态
            {
                SoOrderBo.Instance.UpdatePayStatus(orderID, Hyt.Model.WorkflowStatus.OrderStatus.销售单支付状态.已支付); //更新订单支付状态 余勇修改为调用业务层方法
                if (order != null && order.OnlineStatus == Constant.OlineStatusType.待支付)                       //更新前台显示状态
                {
                    switch (order.Status)
                    {
                    case (int)Hyt.Model.WorkflowStatus.OrderStatus.销售单状态.待审核:
                        SoOrderBo.Instance.UpdateOnlineStatusByOrderID(order.SysNo, Constant.OlineStatusType.待审核);     //更新订单前台显示状态 余勇修改为调用业务层方法  Hyt.DataAccess.Order.ISoOrderDao.Instance.UpdateOnlineStatusByOrderID(orderID, Constant.OlineStatusType.待审核);
                        break;

                    default:
                        SoOrderBo.Instance.UpdateOnlineStatusByOrderID(order.SysNo, Constant.OlineStatusType.待出库);     //更新订单前台显示状态 余勇修改为调用业务层方法  Hyt.DataAccess.Order.ISoOrderDao.Instance.UpdateOnlineStatusByOrderID(orderID, Constant.OlineStatusType.待出库);
                        break;
                    }
                }
                //entity.Status = (int)FinanceStatus.收款单状态.已确认;
            }

            var itemSysNo = Hyt.DataAccess.Finance.IFnReceiptVoucherItemDao.Instance.Insert(item);

            Hyt.DataAccess.Finance.IFnReceiptVoucherDao.Instance.Update(entity);
            //同步支付时间的到订单主表
            ISoOrderDao.Instance.UpdateOrderPayDteById(orderID);
            if (string.IsNullOrEmpty(item.EasReceiptCode))
            {
                SysLog.Instance.WriteLog(LogStatus.SysLogLevel.Warn, LogStatus.系统日志来源.后台, "插入收款明细FnReceiptVoucherItem时EAS收款科目为空,收款单号:" + item.ReceiptVoucherSysNo,
                                         LogStatus.系统日志目标类型.收款单, itemSysNo, null, string.Empty, 0);
            }
        }
Example #2
0
        /// <summary>
        /// 添加收款单明细
        /// </summary>
        /// <param name="model">收款明细</param>
        /// <returns>收款单实收金额</returns>
        /// <remarks>2014-02-13 黄志勇 创建</remarks>
        public decimal AddReceiptVoucherItem(FnReceiptVoucherItem model)
        {
            var items = new List <FnReceiptVoucherItem> {
                model
            };

            CreateReceiptVoucherItem(items);
            //获取收款单实收金额
            decimal total = GetReceiveAmount(model.ReceiptVoucherSysNo);
            //修改收款单实收金额
            var receiptVoucher = GetReceiptVoucher(model.ReceiptVoucherSysNo);

            receiptVoucher.ReceivedAmount = total;
            Update(receiptVoucher);
            return(total);
        }
Example #3
0
        /// <summary>
        /// 二期业务数据1段 财务
        /// </summary>
        /// <param name="listObject"></param>
        private void AddBaseTaskObject2ToList2(List <BaseTask> listObject)
        {
            BaseTask fninvoice = new FnInvoice();

            BaseTask fnpv = new FnReceiptVoucher();
            BaseTask fnReceiptVoucherItem = new FnReceiptVoucherItem();
            BaseTask fnop                 = new FnOnlinePayment();
            BaseTask fnPaymentVoucher     = new FnPaymentVoucher();
            BaseTask fnPaymentVoucherItem = new FnPaymentVoucherItem();



            listObject.Add(fninvoice);
            listObject.Add(fnpv);
            listObject.Add(fnReceiptVoucherItem);
            listObject.Add(fnop);


            listObject.Add(fnPaymentVoucher);
            listObject.Add(fnPaymentVoucherItem);
        }
Example #4
0
        private void AddBaseTaskObjectToList(List <BaseTask> listObject)
        {
            BaseTask bsAT                    = new BsArea();
            BaseTask bsDP                    = new BsDeliveryPayment();
            BaseTask bsPT                    = new BsPaymentType();
            BaseTask bsCode                  = new BsCode();
            BaseTask bsOrganization          = new BsOrganization();
            BaseTask bsOrganizationWarehouse = new BsOrganizationWarehouse();

            BaseTask crCustomer = new CrCustomer();
            BaseTask crCL       = new CrCustomerLevel();
            BaseTask crCQ       = new CrCustomerQuestion();
            BaseTask crRA       = new CrReceiveAddress();

            BaseTask dsMallType      = new DsMallType();
            BaseTask dsDealerLevel   = new DsDealerLevel();
            BaseTask feArticle       = new FeArticle();
            BaseTask feAC            = new FeArticleCategory();
            BaseTask feCS            = new FeCommentSupport();
            BaseTask fepc            = new FeProductComment();
            BaseTask fePCI           = new FeProductCommentImage();
            BaseTask fePCR           = new FeProductCommentReply();
            BaseTask feSearchKeyword = new FeSearchKeyword();
            BaseTask feadvertgroup   = new FeAdvertGroup();
            BaseTask feadvertitem    = new FeAdvertItem();
            BaseTask feproductgroup  = new FeProductGroup();
            BaseTask feproductitem   = new FeProductItem();

            BaseTask fnIT      = new FnInvoiceType();
            BaseTask fninvoice = new FnInvoice();

            BaseTask fnpv = new  FnReceiptVoucher();
            BaseTask fnReceiptVoucherItem = new FnReceiptVoucherItem();
            BaseTask fnop                 = new FnOnlinePayment();
            BaseTask fnPaymentVoucher     = new FnPaymentVoucher();
            BaseTask fnPaymentVoucherItem = new FnPaymentVoucherItem();

            BaseTask lgDelivery              = new LgDelivery();
            BaseTask lgDI                    = new LgDeliveryItem();
            BaseTask lgDS                    = new LgDeliveryScope();
            BaseTask lgDT                    = new LgDeliveryType();
            BaseTask lgDUC                   = new LgDeliveryUserCredit();
            BaseTask lgPT                    = new LgPickupType();
            BaseTask lgsettlement            = new LgSettlement();
            BaseTask lgSI                    = new LgSettlementItem();
            BaseTask lgDeliveryPrintTemplate = new LgDeliveryPrintTemplate();
            BaseTask pdAttribute             = new PdAttribute();
            BaseTask pdAG                    = new PdAttributeGroup();
            BaseTask pdAGA                   = new PdAttributeGroupAssociation();
            BaseTask pdAO                    = new PdAttributeOption();
            BaseTask pdBrand                 = new PdBrand();
            BaseTask pdCGA                   = new PdCatAttributeGroupAso();
            BaseTask pdCategory              = new PdCategory();
            BaseTask pdCA                    = new PdCategoryAssociation();
            BaseTask pdPrice                 = new PdPrice();
            BaseTask pdProduct               = new PdProduct();
            BaseTask pdPA                    = new PdProductAssociation();
            BaseTask pdProductAttribute      = new PdProductAttribute();
            BaseTask pdPI                    = new PdProductImage();
            BaseTask pdTemplate              = new PdTemplate();
            BaseTask pdProductStatistics     = new PdProductStatistics();

            BaseTask soOrder         = new SoOrder();
            BaseTask soOrderItem     = new SoOrderItem();
            BaseTask soRA            = new SoReceiveAddress();
            BaseTask SyUG            = new SyUserGroup();
            BaseTask syGU            = new SyGroupUser();
            BaseTask syMenu          = new SyMenu();
            BaseTask syMenuPrivilege = new SyMenuPrivilege();
            BaseTask syPrivilege     = new SyPrivilege();
            BaseTask syRole          = new SyRole();
            BaseTask syRoleMenu      = new SyRoleMenu();
            BaseTask syRolePrivilege = new SyRolePrivilege();
            BaseTask syPermission    = new SyPermission();
            BaseTask syUser          = new SyUser();
            BaseTask syUW            = new SyUserWarehouse();
            BaseTask syMyMenu        = new SyMyMenu();

            BaseTask spcombo                  = new SpCombo();
            BaseTask spComboItem              = new SpComboItem();
            BaseTask spcopon                  = new spcoupon();
            BaseTask sqpromotion              = new SPpromotion();
            BaseTask spromotiongift           = new SPpromotiongift();
            BaseTask sppromotionoverlay       = new SPpromotionoverlay();
            BaseTask sppromotionrule          = new SPpromotionrule();
            BaseTask sppromotionrulecondition = new SPpromotionrulecondition();
            BaseTask sppromotionrulekeyvalue  = new SPpromotionrulekeyvalue();
            BaseTask syTaskConfig             = new SyTaskConfig();

            BaseTask whStockOut     = new WhStockOut();
            BaseTask whStockOutItem = new WhstockOutItem();
            BaseTask whwarehouse    = new WhWarehouse();
            BaseTask whwa           = new WHwarehousearea();
            BaseTask whwdy          = new WHwarehouseDeliveryType();
            BaseTask whWPT          = new WhWarehousePickupType();
            BaseTask whstockin      = new WhStockIn();
            BaseTask whstockinItem  = new WHStockinItem();
            BaseTask rcReturn       = new RCReturn();
            BaseTask rcReturnItem   = new RcReturnItem();

            listObject.Add(bsAT);
            listObject.Add(bsDP);
            listObject.Add(bsPT);
            listObject.Add(bsCode);
            listObject.Add(bsOrganization);
            listObject.Add(bsOrganizationWarehouse);

            listObject.Add(crCustomer);
            listObject.Add(crCL);
            listObject.Add(crCQ);
            listObject.Add(crRA);
            listObject.Add(dsMallType);
            listObject.Add(dsDealerLevel);
            listObject.Add(feArticle);
            listObject.Add(feAC);
            listObject.Add(feCS);
            listObject.Add(fePCI);
            listObject.Add(fePCR);
            listObject.Add(fepc);
            listObject.Add(feSearchKeyword);
            listObject.Add(feadvertgroup);
            listObject.Add(feadvertitem);
            listObject.Add(feproductgroup);
            listObject.Add(feproductitem);

            listObject.Add(fnIT);
            listObject.Add(fnpv);
            listObject.Add(fnReceiptVoucherItem);
            listObject.Add(fnop);
            listObject.Add(fninvoice);

            listObject.Add(fnPaymentVoucher);
            listObject.Add(fnPaymentVoucherItem);

            listObject.Add(lgDelivery);
            listObject.Add(lgDI);
            listObject.Add(lgDS);
            listObject.Add(lgDT);
            listObject.Add(lgPT);
            listObject.Add(lgsettlement);
            listObject.Add(lgSI);
            listObject.Add(lgDeliveryPrintTemplate);

            listObject.Add(pdAttribute);
            listObject.Add(pdAG);
            listObject.Add(pdAGA);
            listObject.Add(pdAO);
            listObject.Add(pdBrand);
            listObject.Add(pdCGA);
            listObject.Add(pdCategory);
            listObject.Add(pdCA);
            listObject.Add(pdPrice);
            listObject.Add(pdProduct);
            listObject.Add(pdPA);
            listObject.Add(pdProductAttribute);
            listObject.Add(pdTemplate);
            listObject.Add(pdProductStatistics);

            listObject.Add(soOrder);
            listObject.Add(soOrderItem);

            listObject.Add(spcombo);
            listObject.Add(spComboItem);
            listObject.Add(spcopon);
            listObject.Add(sqpromotion);
            listObject.Add(spromotiongift);
            //listObject.Add(sppromotionoverlay);
            listObject.Add(sppromotionrule);
            listObject.Add(sppromotionrulecondition);
            listObject.Add(sppromotionrulekeyvalue);

            listObject.Add(syGU);
            listObject.Add(syUW);
            listObject.Add(SyUG);
            listObject.Add(syMenu);
            listObject.Add(syUser);
            listObject.Add(syPermission);

            listObject.Add(syMenuPrivilege);
            listObject.Add(syPrivilege);
            listObject.Add(syRole);
            listObject.Add(syRoleMenu);
            listObject.Add(syRolePrivilege);
            listObject.Add(syMyMenu);
            listObject.Add(syTaskConfig);

            listObject.Add(whStockOut);
            listObject.Add(whStockOutItem);
            listObject.Add(whwarehouse);
            listObject.Add(whwa);
            listObject.Add(whwdy);
            listObject.Add(whWPT);
            listObject.Add(whstockin);
            listObject.Add(whstockinItem);
            listObject.Add(rcReturn);
            listObject.Add(rcReturnItem);
            listObject.Add(lgDUC);
            listObject.Add(pdPI);
            listObject.Add(soRA);
        }
Example #5
0
        /// <summary>
        /// 门店提货转快递
        /// </summary>
        /// <param name="stockOutSysNo">出库单编号</param>
        /// <param name="receiveAddress">快递收货地址</param>
        /// <param name="reason">转快递原因</param>
        /// <param name="message">会员留言</param>
        /// <param name="invoice">发票 null表示不开发票</param>
        /// <param name="payType">付款方式,现金或者刷卡</param>
        /// <param name="receiveMoney">收款金额 null 表示无应收款</param>
        /// <param name="voucherNo">刷卡流水号</param>
        /// <param name="easReceiptCode">eas收款科目编号</param>
        /// <returns></returns>
        /// <remarks>
        /// 2013-07-08 朱成果 创建
        /// 2013/10/14 朱家宏 增加 voucherNo参数
        /// </remarks>
        public void SetOrderToCourier(int stockOutSysNo, SoReceiveAddress receiveAddress, string reason, string message, FnInvoice invoice, int payType, decimal?receiveMoney, SyUser user, string voucherNo, string easReceiptCode = null)
        {
            var model = SetOutOfStock(stockOutSysNo, reason, user, false);                                                                //作废出库单

            Hyt.BLL.Order.SoOrderBo.Instance.WriteSoTransactionLog(model.TransactionSysNo, "出库单门店自提转快递:" + stockOutSysNo, user.UserName); //转快递日志
            var order = SoOrderBo.Instance.GetEntity(model.OrderSysNO);                                                                   //更新订单信息

            if (order == null)
            {
                throw new Exception("订单信息不存在");
            }

            order.DeliveryTypeSysNo = DeliveryType.第三方快递;    //修改配送方式
            if (payType > 0)
            {
                order.PayTypeSysNo = payType;   //门店现付
            }
            else if (order.PayStatus == (int)Hyt.Model.WorkflowStatus.OrderStatus.销售单支付状态.未支付)
            {
                order.PayTypeSysNo = (int)PaymentType.现金预付;
            }
            order.Status                       = (int)Hyt.Model.WorkflowStatus.OrderStatus.销售单状态.待审核;
            order.InternalRemarks              = "【门店转快递】:" + reason;
            order.CustomerMessage              = message;                                                                            //会员留言
            order.ReceiveAddress               = Hyt.BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo); //收货地址
            order.ReceiveAddress.AreaSysNo     = receiveAddress.AreaSysNo;                                                           //收货地区
            order.ReceiveAddress.StreetAddress = receiveAddress.StreetAddress;                                                       //详细收货地址
            if (invoice == null)
            {
                order.InvoiceSysNo = 0;    //发票
            }
            else
            {
                //以前没有创建发票
                if (order.InvoiceSysNo == 0)
                {
                    order.OrderInvoice = new FnInvoice
                    {
                        CreatedBy      = user.SysNo,
                        CreatedDate    = DateTime.Now,
                        InvoiceRemarks = invoice.InvoiceRemarks,
                        InvoiceTitle   = invoice.InvoiceTitle,

                        InvoiceTypeSysNo = invoice.InvoiceTypeSysNo,
                        InvoiceAmount    = order.CashPay,
                        Status           = 10,
                        TransactionSysNo = model.TransactionSysNo
                    };
                    order.InvoiceSysNo = Hyt.BLL.Order.SoOrderBo.Instance.InsertOrderInvoice(order.OrderInvoice);
                }
                else      //以前有发票
                {
                    order.OrderInvoice = Hyt.BLL.Order.SoOrderBo.Instance.GetFnInvoice(order.InvoiceSysNo);
                    order.OrderInvoice.LastUpdateBy   = user.SysNo;
                    order.OrderInvoice.LastUpdateDate = DateTime.Now;
                    order.OrderInvoice.InvoiceTitle   = invoice.InvoiceTitle;

                    order.OrderInvoice.InvoiceTypeSysNo = invoice.InvoiceTypeSysNo;
                    order.OrderInvoice.InvoiceAmount    = order.CashPay;
                    Hyt.BLL.Order.SoOrderBo.Instance.UpdateOrderInvoice(order.OrderInvoice);
                }
            }
            var warehouse = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWhWareHouse(receiveAddress.AreaSysNo, null, (int)Hyt.Model.SystemPredefined.DeliveryType.第三方快递, WarehouseStatus.仓库状态.启用).FirstOrDefault();

            if (warehouse != null)
            {
                order.DefaultWarehouseSysNo = warehouse.SysNo; //快递仓库默认为当前仓库
            }
            SoOrderBo.Instance.UpdateOrder(order);             //更新订单 余勇 修改为调用业务层方法
            //Hyt.DataAccess.Order.ISoOrderDao.Instance.Update(order);//更新订单

            SoOrderBo.Instance.SaveSoReceiveAddress(order.ReceiveAddress);    //保存订单收货地址

            //更新收款明细
            if (receiveMoney.HasValue)
            {
                FnReceiptVoucherItem item = new FnReceiptVoucherItem()
                {
                    Amount               = receiveMoney.Value,
                    CreatedBy            = user.SysNo,
                    CreatedDate          = DateTime.Now,
                    PaymentTypeSysNo     = payType,
                    TransactionSysNo     = order.TransactionSysNo,
                    Status               = (int)Model.WorkflowStatus.FinanceStatus.收款单明细状态.效,
                    VoucherNo            = voucherNo,
                    EasReceiptCode       = easReceiptCode,
                    ReceivablesSideType  = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款方类型.仓库, //收款单仓库
                    ReceivablesSideSysNo = model.WarehouseSysNo                                  //仓库编号
                };
                Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.InsertOrderReceiptVoucher(order.SysNo, item);
                if (receiveMoney.HasValue && (payType == (int)Hyt.Model.SystemPredefined.PaymentType.现金 || payType == (int)Hyt.Model.SystemPredefined.PaymentType.现金预付))
                {
                    Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.AutoConfirmReceiptVoucher(order.SysNo, user);    //收现金自动确认收款单
                }
            }
            //同步支付时间的到订单主表
            ISoOrderDao.Instance.UpdateOrderPayDteById(order.SysNo);
            //写订单池记录
            SyJobPoolPublishBo.Instance.OrderAuditBySysNo(order.SysNo);
            SyJobDispatcherBo.Instance.WriteJobLog(string.Format("门店提货转快递创建订单审核任务,销售单编号:{0}",
                                                                 order.SysNo), order.SysNo, null, user.SysNo);
        }
Example #6
0
        /// <summary>
        /// 门店提货
        /// </summary>
        /// <param name="sysNo">出库单</param>
        /// <param name="payMoney">收款金额,如为空表已付款</param>
        /// <param name="PaymentType">PaymentType.现金或者 PaymentType.刷卡</param>
        /// <param name="user">操作人</param>
        /// <param name="invoice">发票 null表示不开发票</param>
        /// <param name="voucherNo">收款单明细-交易凭证号</param>
        /// <param name="withTran">是否事物方式提交</param>
        /// <param name="easReceiptCode">EAS收款科目编码</param>
        /// <returns></returns>
        /// <remarks>
        /// 2013-07-08 朱成果 创建
        /// 2013/10/14 朱家宏 增加 voucherNo参数
        /// </remarks>
        public void PickUp(int sysNo, decimal?payMoney, int PaymentType, Hyt.Model.SyUser user, FnInvoice invoice, string voucherNo, bool withTran = true, string easReceiptCode = null)
        {
            var entity = Hyt.DataAccess.Warehouse.IOutStockDao.Instance.GetModel(sysNo);

            if (entity == null)
            {
                throw new Exception("出库单不存在");
            }
            if (entity.Status == (int)Hyt.Model.WorkflowStatus.WarehouseStatus.出库单自提状态.已自提)
            {
                throw new Exception("该出库单商品已被提货。");
            }
            var mydel = new PickUpDel(delegate(WhStockOut xx)
            {
                if (invoice != null)                                                                                      //新开发票
                {
                    var fninvoice = Hyt.DataAccess.Order.IFnInvoiceDao.Instance.GetFnInvoiceByOrderID(entity.OrderSysNO); //是否已经设置了发票信息
                    if (fninvoice == null)
                    {
                        invoice.CreatedBy   = user.SysNo;
                        invoice.CreatedDate = DateTime.Now;
                        invoice.Status      = (int)Hyt.Model.WorkflowStatus.FinanceStatus.发票状态.已开票;

                        //2013/10/21 朱家宏 添加
                        invoice.LastUpdateDate   = DateTime.Now;
                        invoice.LastUpdateBy     = user.SysNo;
                        invoice.TransactionSysNo = SoOrderBo.Instance.GetEntity(xx.OrderSysNO).TransactionSysNo;

                        int newid       = Hyt.DataAccess.Order.IFnInvoiceDao.Instance.InsertEntity(invoice);
                        xx.InvoiceSysNo = newid;                                         //出库单关联发票
                        SoOrderBo.Instance.UpdateOrderInvoice(entity.OrderSysNO, newid); //更新订单关联发票 余勇修改为调用业务方法 Hyt.DataAccess.Order.ISoOrderDao.Instance.UpdateInvoiceNo(entity.OrderSysNO, newid);//订单关联发票
                    }
                    else
                    {
                        if (fninvoice.Status == (int)Hyt.Model.WorkflowStatus.FinanceStatus.发票状态.已开票)
                        {
                            throw new Exception("已经开具发票,不能重复开票");
                        }
                        else
                        {
                            invoice.LastUpdateBy   = user.SysNo;
                            invoice.LastUpdateDate = DateTime.Now;
                            invoice.InvoiceAmount  = fninvoice.InvoiceAmount;
                            invoice.Status         = (int)Hyt.Model.WorkflowStatus.FinanceStatus.发票状态.已开票;
                            invoice.SysNo          = fninvoice.SysNo;
                            Hyt.BLL.Order.SoOrderBo.Instance.UpdateOrderInvoice(invoice); //更新发票 余勇 修改 改为调用业务层方法
                            //Hyt.DataAccess.Order.IFnInvoiceDao.Instance.UpdateEntity(invoice);
                        }
                    }
                }
                xx.Status       = (int)Hyt.Model.WorkflowStatus.WarehouseStatus.出库单自提状态.已自提;
                xx.StockOutBy   = user.SysNo;
                xx.StockOutDate = DateTime.Now;
                xx.SignTime     = DateTime.Now;
                if (payMoney.HasValue)
                {
                    if (payMoney.Value > xx.Receivable)
                    {
                        throw new Exception("收款金额大于应收金额");
                    }
                    // xx.Receivable = xx.Receivable - payMoney.Value;
                }
                Hyt.DataAccess.Warehouse.IOutStockDao.Instance.Update(xx);       //更新出库单状态
                GenerateOtherDataForPickUp(entity, user, payMoney, PaymentType); //创建已签收配送单,已结算结算单
                //更新收款明细
                if (payMoney.HasValue)
                {
                    FnReceiptVoucherItem item = new FnReceiptVoucherItem()
                    {
                        Amount               = payMoney.Value,
                        CreatedBy            = user.SysNo,
                        CreatedDate          = DateTime.Now,
                        PaymentTypeSysNo     = PaymentType,
                        TransactionSysNo     = entity.TransactionSysNo,
                        Status               = (int)Model.WorkflowStatus.FinanceStatus.收款单明细状态.效,
                        VoucherNo            = voucherNo,
                        EasReceiptCode       = easReceiptCode,
                        ReceivablesSideType  = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款方类型.仓库, //收款单仓库
                        ReceivablesSideSysNo = entity.WarehouseSysNo                                 //仓库编号
                    };
                    Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.InsertOrderReceiptVoucher(xx.OrderSysNO, item);
                }
                //同步支付时间的到订单主表
                ISoOrderDao.Instance.UpdateOrderPayDteById(xx.OrderSysNO);
                Hyt.BLL.Order.SoOrderBo.Instance.UpdateSoStatusForSotckOutSign(xx, user);  //订单完成,并加积分
            });

            //外层都使用了事务将此方法包含起来,所以注释掉此段代码
            //if (withTran)
            //{
            //    using (var tran = new TransactionScope())
            //    {
            //        mydel(entity);
            //        tran.Complete();
            //    }
            //}
            //else
            //{
            mydel(entity);
            //}
            try
            {
                //a)	门店下单(付现)提货动作后自动确认收款单
                //b)	门店自提货到付款(付现)提货后自动确认收款单
                // 自动确认收款单,并写Eas数据
                if (payMoney.HasValue && (PaymentType == (int)Hyt.Model.SystemPredefined.PaymentType.现金 || PaymentType == (int)Hyt.Model.SystemPredefined.PaymentType.现金预付))
                {
                    Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.AutoConfirmReceiptVoucher(entity.OrderSysNO, user);
                }



                //修改ERP库存
                //Hyt.BLL.Warehouse.WhWarehouseBo.Instance.UpdateErpProductNumber(sysNo);
                //修改库存
                //Hyt.BLL.Warehouse.WhWarehouseBo.Instance.UpdateWarehouseProductStock(sysNo);
            }
            catch (Exception ex)
            {
                Hyt.BLL.Log.SysLog.Instance.WriteLog(LogStatus.SysLogLevel.Error, LogStatus.系统日志来源.后台, "门店提货或者门店下单提货",
                                                     LogStatus.系统日志目标类型.EAS, sysNo, ex, string.Empty, user.SysNo);
            }
        }
Example #7
0
        /// <summary>
        /// 添加网上支付(单据来源:订单)
        /// </summary>
        /// <param name="onlinePayment">数据实体</param>
        /// <returns>sysNo</returns>
        /// <remarks>2013-07-18 朱家宏 创建</remarks>
        /// <remarks>2013-11-1 黄志勇 修改</remarks>
        public int CreateOnlinePaymentFromSoOrder(FnOnlinePayment onlinePayment)
        {
            /*
             * 1.支付方式类型为预付&&未付款的订单
             * 2.修改订单相关:支付状态改为已支付 订单状态如果为待支付改为待创建出库单
             * 3.根据收款单单据来源和单据来源编号,创建收款单明细
             */

            if (onlinePayment == null)
            {
                throw new ArgumentNullException("onlinePayment");
            }

            onlinePayment.Source = (int)FinanceStatus.网上支付单据来源.销售单;
            onlinePayment.Status = (int)FinanceStatus.网上支付状态.效;

            var soOrder     = SoOrderBo.Instance.GetEntity(onlinePayment.SourceSysNo);
            var payStatus   = soOrder.PayStatus;
            var paymentType = Basic.PaymentTypeBo.Instance.GetEntity(soOrder.PayTypeSysNo).PaymentType;

            //创建网上支付记录
            var r = 0;

            if (paymentType == (int)BasicStatus.支付方式类型.预付 &&
                payStatus == (int)OrderStatus.销售单支付状态.未支付)
            {
                r = IFnOnlinePaymentDao.Instance.Insert(onlinePayment);
            }

            if (r == 0)
            {
                return(r);
            }


            var userName = Sys.SyUserBo.Instance.GetUserName(onlinePayment.CreatedBy);//创建人姓名

            SoOrderBo.Instance.WriteSoTransactionLog(soOrder.TransactionSysNo,
                                                     string.Format(Constant.ORDER_TRANSACTIONLOG_PAY,
                                                                   Util.FormatUtil.FormatCurrency(
                                                                       onlinePayment.Amount, 2)),
                                                     userName);
            //创建收款单明细
            var receiptVoucherItem = new FnReceiptVoucherItem
            {
                Amount              = onlinePayment.Amount,
                CreatedBy           = onlinePayment.CreatedBy,
                LastUpdateBy        = onlinePayment.CreatedBy,
                VoucherNo           = onlinePayment.VoucherNo,
                PaymentTypeSysNo    = soOrder.PayTypeSysNo,
                TransactionSysNo    = soOrder.TransactionSysNo,
                CreatedDate         = DateTime.Now,
                LastUpdateDate      = DateTime.Now,
                Status              = (int)FinanceStatus.收款单明细状态.效,
                ReceivablesSideType = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款方类型.财务中心,
            };

            //插入收款单,收款明细,
            FnReceiptVoucherBo.Instance.InsertOrderReceiptVoucher(onlinePayment.SourceSysNo, receiptVoucherItem, false);
            //同步支付时间的到订单主表
            ISoOrderDao.Instance.UpdateOrderPayDteById(soOrder.SysNo);
            return(r);
        }
Example #8
0
 /// <summary>
 /// 修改收款单明细
 /// </summary>
 /// <param name="item">收款单明细实体</param>
 /// <returns>void</returns>
 /// <remarks>2013-08-07 黄伟 创建</remarks>
 public override void Update(FnReceiptVoucherItem item)
 {
     Context.Update <FnReceiptVoucherItem>("FnReceiptVoucherItem", item)
     .AutoMap(p => p.SysNo).Where("SysNo", item.SysNo).Execute();
 }
Example #9
0
        ///  <summary>
        ///  门店提货或者转快递,插入收款明细
        ///  </summary>
        /// <param name="order">订单</param>
        /// <param name="item">收款明细</param>
        ///  <returns></returns>
        /// <remarks>2013-07-08 朱成果 创建</remarks>
        /// <remarks>2014-05-13 何方 重构 使用SoOrder 实体,避免重复查询SoOrder</remarks>
        public void InsertOrderReceiptVoucher(SoOrder order, FnReceiptVoucherItem item)
        {
            //收款单
            //var order = Grand.DataAccess.Order.ISoOrderDao.Instance.GetEntity(orderID);
            var entity = DataAccess.Finance.IFnReceiptVoucherDao.Instance.GetEntity(sourceFromOrder, order.SysNo);

            if (entity == null) //不存在收款单创建一条记录
            {
                entity = CreateReceiptVoucherByOrder(order);
            }


            item.ReceiptVoucherSysNo = entity.SysNo;//收款单编号
            item.TransactionSysNo    = entity.TransactionSysNo;
            item.Status = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款单明细状态.效;


            entity.ReceivedAmount += item.Amount;

            SysLog.Instance.Info(LogStatus.系统日志来源.后台, string.Format("已支付金额{0},应付金额{1}", entity.ReceivedAmount, entity.IncomeAmount), LogStatus.系统日志目标类型.订单,
                                 order.SysNo, null, WebUtil.GetUserIp(), item.CreatedBy);

            if (entity.ReceivedAmount > entity.IncomeAmount)
            {
                SysLog.Instance.Error(LogStatus.系统日志来源.后台, string.Format("已支付金额{0}超过了应收款金额{1}", entity.ReceivedAmount, entity.IncomeAmount), LogStatus.系统日志目标类型.订单,
                                      order.SysNo, item.CreatedBy);

                throw new HytException(string.Format("已支付金额{0}超过了应收款金额{1}", entity.ReceivedAmount, entity.IncomeAmount));
            }
            if (entity.ReceivedAmount == entity.IncomeAmount) //更新订单的支付状态
            {
                DataAccess.Order.ISoOrderDao.Instance.UpdatePayStatus(order.SysNo, (int)Model.WorkflowStatus.OrderStatus.销售单支付状态.已支付);
                BLL.Log.SysLog.Instance.Info(LogStatus.系统日志来源.后台, "已支付金额等于应付金额,将修改订单支付状态为已付款", LogStatus.系统日志目标类型.订单,
                                             order.SysNo, item.CreatedBy);



                if (order != null && order.OnlineStatus == Constant.OlineStatusType.待支付) //更新前台显示状态
                {
                    switch (order.Status)
                    {
                    case (int)Model.WorkflowStatus.OrderStatus.销售单状态.待审核:
                        DataAccess.Order.ISoOrderDao.Instance.UpdateOnlineStatusByOrderID(order.SysNo,
                                                                                          Constant.OlineStatusType.待审核);
                        break;

                    default:
                        DataAccess.Order.ISoOrderDao.Instance.UpdateOnlineStatusByOrderID(order.SysNo,
                                                                                          Constant.OlineStatusType.待出库);
                        break;
                    }
                }
                //entity.Status = (int)FinanceStatus.收款单状态.已确认;
            }
            else
            {
                SysLog.Instance.Info(LogStatus.系统日志来源.后台, "已支付金额不足应付金额,没有修订单支付状态", LogStatus.系统日志目标类型.订单,
                                     order.SysNo, null, WebUtil.GetUserIp(), item.CreatedBy);
            }

            var itemSysNo = DataAccess.Finance.IFnReceiptVoucherItemDao.Instance.Insert(item);

            DataAccess.Finance.IFnReceiptVoucherDao.Instance.Update(entity);
            //同步支付时间的到订单主表
            ISoOrderDao.Instance.UpdateOrderPayDteById(order.SysNo);
            if (string.IsNullOrEmpty(item.EasReceiptCode))
            {
                SysLog.Instance.WriteLog(LogStatus.SysLogLevel.Warn, LogStatus.系统日志来源.后台, "插入收款明细FnReceiptVoucherItem时EAS收款科目为空,收款单号:" + item.ReceiptVoucherSysNo,
                                         LogStatus.系统日志目标类型.收款单, itemSysNo, null, string.Empty, 0);
            }
        }
Example #10
0
        /// <summary>
        /// 创建二次销售订单
        /// </summary>
        /// <param name="order">订单信息</param>
        /// <param name="user">用户信息</param>
        /// <param name="hasDelivery">是否配送员立即配送</param>
        /// <returns></returns>
        /// <remarks>2014-9-17  朱成果 创建</remarks>
        public AppOrder CreateTwoSaleSoOrder(AppOrder order, SyUser user, bool hasDelivery = true)
        {
            CheckAppOrder(order, user);//验证订单数据

            #region 创建销售单
            var payType = PaymentTypeBo.Instance.GetPaymentTypeFromMemory(order.SoOrder.PayTypeSysNo);
            order.SoOrder.OnlineStatus          = payType.PaymentType == (int)BasicStatus.支付方式类型.到付 ? Constant.OlineStatusType.待审核 : Constant.OlineStatusType.待支付;
            order.SoOrder.Status                = (int)OrderStatus.销售单状态.待审核;
            order.SoOrder.PayStatus             = (int)OrderStatus.销售单支付状态.未支付;
            order.SoOrder.OrderCreatorSysNo     = order.SoOrder.LastUpdateBy = user.SysNo;
            order.SoOrder.CreateDate            = order.SoOrder.LastUpdateDate = DateTime.Now;
            order.SoOrder.DefaultWarehouseSysNo = BLL.Warehouse.WhWarehouseBo.Instance.GetDeliveryUserWarehouseSysNo(user.SysNo);//获取仓库信息
            order.SoOrder.OrderSource           = (int)OrderStatus.销售单来源.业务员下单;
            order.SoOrder.OrderSourceSysNo      = user.SysNo;
            if (order.SoOrder.DefaultWarehouseSysNo < 1)
            {
                throw new HytException("配送员仓库信息获取失败");
            }
            var whinfo = WhWarehouseBo.Instance.GetWarehouse(order.SoOrder.DefaultWarehouseSysNo); //仓库信息
            if (hasDelivery)                                                                       //马上配送
            {
                order.SoOrder.DeliveryTypeSysNo = DeliveryType.普通百城当日达;
                if (payType.PaymentType == (int)BasicStatus.支付方式类型.到付)//此情况不允许下到付订单
                {
                    throw new HytException("此流程必须先收款。");
                }
            }
            else//不必立刻配送
            {
                bool Isdrd = false;//是否满足当日达
                if (whinfo != null)
                {
                    var zb = Hyt.BLL.Map.BaiduMapAPI.Instance.Geocoder(order.SoReceiveAddress.StreetAddress, whinfo.CityName);//仓库所在城市->收货地址
                    if (zb != null)
                    {
                        Isdrd = LgDeliveryScopeBo.Instance.IsInScope(whinfo.CitySysNo, new Coordinate()
                        {
                            X = zb.Lng, Y = zb.Lat
                        });                                                                                                        //是否支持当日达
                    }
                }
                order.SoOrder.DeliveryTypeSysNo = Isdrd?DeliveryType.普通百城当日达:DeliveryType.第三方快递;
            }
            ISoReceiveAddressDao.Instance.InsertEntity(order.SoReceiveAddress); //收货地址
            order.SoOrder.ReceiveAddressSysNo = order.SoReceiveAddress.SysNo;   //收货地址
            if (order.Invoice != null)                                          //发票信息
            {
                order.Invoice.Status      = FinanceStatus.发票状态.待开票.GetHashCode();
                order.Invoice.CreatedBy   = order.Invoice.LastUpdateBy = user.SysNo;
                order.Invoice.CreatedDate = order.Invoice.LastUpdateDate = DateTime.Now;
                IFnInvoiceDao.Instance.InsertEntity(order.Invoice);
                order.SoOrder.InvoiceSysNo = order.Invoice.SysNo;
            }
            ISoOrderDao.Instance.InsertEntity(order.SoOrder);                  //创建订单
            order.SoOrder = SoOrderBo.Instance.GetEntity(order.SoOrder.SysNo); //获取订单
            foreach (var item in order.Products)                               //创建订单明细
            {
                item.OrderSysNo       = order.SoOrder.SysNo;
                item.TransactionSysNo = order.SoOrder.TransactionSysNo;
                item.SysNo            = ISoOrderItemDao.Instance.Insert(item);
            }
            SoOrderBo.Instance.WriteSoTransactionLog(order.SoOrder.TransactionSysNo, string.Format(Constant.ORDER_TRANSACTIONLOG_CREATE, order.SoOrder.SysNo), user.UserName);//创建订单日志
            #endregion

            #region 订单收款单
            decimal shoupay = SoOrderBo.Instance.SynchronousOrderAmount(order.SoOrder.SysNo, true); //同步订单价格
            order.SoOrder.CashPay             = shoupay;
            order.SoOrder.ProductChangeAmount = order.Products.Sum(m => m.ChangeAmount);            //记录调价总额
            Finance.FnReceiptVoucherBo.Instance.CreateReceiptVoucherByOrder(order.SoOrder);         //创建订单收款单
            if (payType.PaymentType == (int)BasicStatus.支付方式类型.预付)
            {
                var easinfo = Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.GetFnReceiptTitleAssociation(order.SoOrder.DefaultWarehouseSysNo, payType.SysNo).OrderByDescending(m => m.IsDefault).FirstOrDefault();//eas信息
                FnReceiptVoucherItem fvitem = new FnReceiptVoucherItem()
                {
                    Amount               = order.SoOrder.CashPay,
                    CreatedDate          = DateTime.Now,
                    PaymentTypeSysNo     = order.SoOrder.PayTypeSysNo,
                    TransactionSysNo     = order.SoOrder.TransactionSysNo,
                    Status               = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款单明细状态.效,
                    EasReceiptCode       = easinfo == null?string.Empty:easinfo.EasReceiptCode,  //eas收款科目
                    ReceivablesSideType  = (int)Hyt.Model.WorkflowStatus.FinanceStatus.收款方类型.仓库, //收款方来源
                    ReceivablesSideSysNo = order.SoOrder.DefaultWarehouseSysNo,
                    CreatedBy            = user.SysNo
                };
                Finance.FnReceiptVoucherBo.Instance.InsertOrderReceiptVoucher(order.SoOrder.SysNo, fvitem);       //插入收款单明细
                Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.AutoConfirmReceiptVoucher(order.SoOrder.SysNo, user); //收现金自动确认收款单
                if (order.SoOrder.PayTypeSysNo == PaymentType.现金预付)
                {
                    InsertTwoSaleCashHistory(
                        new Rp_业务员二次销售()
                    {
                        CreateDate        = order.SoOrder.CreateDate,
                        DeliveryUserSysNo = user.SysNo,
                        DeliveryUserName  = user.UserName,
                        StockSysNo        = whinfo.SysNo,
                        StockName         = whinfo.WarehouseName,
                        OrderSysNo        = order.SoOrder.SysNo,
                        OrderAmount       = order.SoOrder.CashPay
                    }
                        );
                }//二次销售收款记录
            }
            #endregion
            //同步支付时间的到订单主表
            ISoOrderDao.Instance.UpdateOrderPayDteById(order.SoOrder.SysNo);
            #region 创建审单任务(可选)
            if (!hasDelivery)                                                       //未配送
            {
                SyJobPoolPublishBo.Instance.OrderAuditBySysNo(order.SoOrder.SysNo); //创建审单任务
                SyJobDispatcherBo.Instance.WriteJobLog(string.Format("二次销售下单成功创建订单审核任务,销售单编号:{0}", order.SoOrder.SysNo), order.SoOrder.SysNo, null, 0);
            }
            #endregion

            return(order);
        }
 /// <summary>
 /// 修改收款单明细
 /// </summary>
 /// <param name="item">收款单明细实体</param>
 /// <returns>2013-08-07 黄伟 创建</returns>
 public abstract void Update(FnReceiptVoucherItem item);
 /// <summary>
 /// 插入收款明细
 /// </summary>
 /// <param name="entity">收款明细</param>
 /// <returns></returns>
 /// <remarks>2013-07-08 朱成果 创建</remarks>
 public abstract int Insert(FnReceiptVoucherItem entity);