/// <summary> /// 终止代销商品规则 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual ConsignSettlementRulesInfo StopConsignSettlementRule(string settleRulesCode) { ConsignSettlementRulesInfo entity = ConsignSettlementRuleDA.GetConsignSettleRuleByCode(settleRulesCode); if (entity == null) { //规则({0})不存在,无法终止 throw new BizException(string.Format(GetExceptionString("ConsignRule_RuleNotExist_Stop"), settleRulesCode)); } if (entity.Status != ConsignSettleRuleStatus.Available && entity.Status != ConsignSettleRuleStatus.Enable) { //规则({0})不处于“未生效”和“已生效”状态,无法终止 throw new BizException(string.Format(GetExceptionString("ConsignRule_Available_Invalid_Stop"), settleRulesCode)); } entity.Status = ConsignSettleRuleStatus.Stop; entity.EditUser = ExternalDomainBroker.GetUserNameByUserSysNo(ServiceContext.Current.UserSysNo); entity = Modify(entity, ConsignSettleRuleActionType.Stop); //记录系统日志 //WriteLog(entity, LogType.ConsignSettleRule_Stop); ExternalDomainBroker.CreateLog(" Stop ConsignSettleRule " , BizEntity.Common.BizLogType.ConsignSettleRule_Stop , entity.RuleSysNo.Value , entity.CompanyCode); return(entity); }
/// <summary> /// 审核供应商代收结算信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo AuditGatherSettlement(GatherSettlementInfo info) { GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info); if (oldSettle.SettleStatus != GatherSettleStatus.ORG) { //该结算单不是待审核状态,不能进行审核操作 throw new BizException(GetMessageString("Gather_Orgin_Invalid_Audit")); } //if (oldSettle.InUser == info.AuditUser.UserDisplayName) //{ // //创建人和审核人不能相同 // throw new BizException(GetMessageString("Gather_WaitingAudit_CreateUser")); //} //更新代收结算单状态: info.SettleStatus = GatherSettleStatus.AUD; GatherSettlementDA.UpdateGatherSettlementStatus(info, true); //发送审核Message EventPublisher.Publish(new GatherSettlementAuditedMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写Log: //CommonService.WriteLog<VendorSettleGatherEntity>(entity, " Audit Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" Audit Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 审核通过成本变价单信息 /// </summary> /// <param name="costChangeInfo"></param> /// <returns></returns> public virtual CostChangeInfo AuditCostChange(CostChangeInfo costChangeInfo) { TransactionOptions option = new TransactionOptions(); //option.IsolationLevel = IsolationLevel.ReadUncommitted; option.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, option)) { costChangeInfo.CostChangeBasicInfo.Status = CostChangeStatus.Audited; //修改单据状态 costChangeInfo = CostChangeDA.UpdateCostChangeAuditStatus(costChangeInfo); //调用Inventory接口:更新库存成本 ExternalDomainBroker.UpdateCostInWhenCostChange(costChangeInfo); //调用Invoice接口:生成结算单的付款单 ExternalDomainBroker.CreatePayItem(new PayItemInfo() { OrderSysNo = costChangeInfo.SysNo.Value, PayAmt = costChangeInfo.CostChangeBasicInfo.TotalDiffAmt, OrderType = PayableOrderType.CostChange, PayStyle = PayItemStyle.Normal, CompanyCode = costChangeInfo.CompanyCode }); //记录日志 ExternalDomainBroker.CreateLog("Audit CostChange" , BizEntity.Common.BizLogType.CostChange_Audit , costChangeInfo.SysNo.Value, costChangeInfo.CompanyCode); ts.Complete(); } return(costChangeInfo); }
/// <summary> /// 创建成本变价单 /// </summary> /// <param name="costChangeInfo">成本变价单Entity</param> /// <returns></returns> public virtual CostChangeInfo CreateCostChange(CostChangeInfo costChangeInfo) { #region [Check 实体逻辑] //VerifyCreate(consignSettleInfo); //VerifySettleItems(consignSettleInfo, SettlementVerifyType.CREATE); #endregion decimal totalDiffAmt = 0; using (TransactionScope scope = new TransactionScope()) { costChangeInfo.CostChangeItems.ForEach(delegate(CostChangeItemsInfo ItemInfo) { totalDiffAmt += (ItemInfo.NewPrice - ItemInfo.OldPrice) * ItemInfo.ChangeCount; }); costChangeInfo.CostChangeBasicInfo.InUser = ServiceContext.Current.UserSysNo; costChangeInfo.CostChangeBasicInfo.Status = CostChangeStatus.Created; costChangeInfo.CostChangeBasicInfo.TotalDiffAmt = totalDiffAmt; costChangeInfo = CostChangeDA.CreateCostChange(costChangeInfo); //写日志 ExternalDomainBroker.CreateLog("Create CostChange" , BizEntity.Common.BizLogType.CostChange_Create , costChangeInfo.SysNo.Value, costChangeInfo.CompanyCode); scope.Complete(); } return(costChangeInfo); }
/// <summary> /// 关闭佣金信息 /// </summary> /// <param name="commissionMaster"></param> /// <returns></returns> public virtual CommissionMaster CloseCommission(CommissionMaster commissionMaster) { //预先检查状态是否满足关闭条件: string checkMsg = BatchCheckCommissionStatus(new List <BizEntity.PO.CommissionMaster>() { commissionMaster }); if (!string.IsNullOrEmpty(checkMsg)) { throw new BizException(checkMsg); } //关闭佣金操作: int result = CommissionDA.CloseCommission(commissionMaster); if (result != 0) { //记录关闭日志: string logMsg = string.Format(GetMessageString("Commission_CloseCommissionFormat"), string.Empty, DateTime.Now, commissionMaster.SysNo.Value); ExternalDomainBroker.CreateLog(logMsg , BizEntity.Common.BizLogType.Commission_CloseCommission , commissionMaster.SysNo.Value , commissionMaster.CompanyCode); } return(commissionMaster); }
/// <summary> /// 批量删除采购篮商品 /// </summary> /// <param name="itemList"></param> /// <returns></returns> public virtual List <BasketItemsInfo> BatchDeleteBasketItems(List <BasketItemsInfo> itemList) { using (TransactionScope scope = new TransactionScope()) { if (null != itemList && 0 < itemList.Count) { foreach (BasketItemsInfo entity in itemList) { if (!entity.ItemSysNo.HasValue || entity.ItemSysNo == 0) { //系统编号不能为空! throw new BizException(GetMessageString("Basket_SysNoEmpty")); } BasketDA.DeleteBasketItem(entity); //写LOG: // CommonService.WriteLog<BasketItemEntity>(entity, " Deleted BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Delete); ExternalDomainBroker.CreateLog(" Deleted BaksetItem " , BizEntity.Common.BizLogType.Purchase_Basket_Delete , entity.ItemSysNo.Value , entity.CompanyCode); } } scope.Complete(); } return(itemList); }
/// <summary> /// 代收结算单 - 取消审核 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo CancelAuditGatherSettlement(GatherSettlementInfo info) { GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info); if (oldSettle.SettleStatus != GatherSettleStatus.AUD) { //该结算单不是已审核状态,不能进行取消审核操作! throw new BizException(GetMessageString("Gather_Audited_Invalid_CancelAudit")); } info.SettleStatus = GatherSettleStatus.ORG; GatherSettlementDA.UpdateGatherSettlementStatus(info, false); //发送取消审核Message EventPublisher.Publish(new GatherSettlementAuditCanceledMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写LOG: // CommonService.WriteLog<VendorSettleGatherEntity>(entity, " CancelAudited Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" CancelAudited Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 代收结算单 - 取消作废 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo CancelAbandonGatherSettlement(GatherSettlementInfo info) { //写LOG:CommonService.WriteLog<VendorSettleGatherEntity>(entity, " CancelAbandon VendorSettle ", entity.SysNo.Value.ToString(), (int)LogType.VendorSettle_CancelAbandon); ExternalDomainBroker.CreateLog(" CancelAbandon Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 创建/更新 采购篮商品 /// </summary> /// <param name="basketInfo"></param> /// <returns></returns> public virtual BasketItemsInfo SaveBasket(BasketItemsInfo basketInfo) { #region [Check 实体逻辑] //检查商品数量: if (!basketInfo.Quantity.HasValue || basketInfo.Quantity.Value == 0) { //{0}:该商品数量不能为空 throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), basketInfo.ProductID)); } if (!basketInfo.OrderPrice.HasValue) { //{0}:该商品结算价不能为空! throw new BizException(string.Format(GetMessageString("Basket_SettlePriceEmpty"), basketInfo.ProductID)); } //商品编号: if (!basketInfo.ProductSysNo.HasValue || basketInfo.ProductSysNo == 0) { //{0}:该商品编号不能为空! throw new BizException(string.Format(GetMessageString("Basket_ItemSysNoEmpty"), basketInfo.ProductID)); } //商品是否存在于采购篮中: else if (BasketDA.CheckProductHasExistInBasket(basketInfo)) { //{0}:该商品已存在于采购篮中! throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), basketInfo.ProductID)); } #endregion //保存和更新操作: if (basketInfo.ItemSysNo == null || !basketInfo.ItemSysNo.HasValue || basketInfo.ItemSysNo.Value == 0) { //如果不存在SysNo,则为新建操作: basketInfo = BasketDA.CreateBasketItem(basketInfo); //写LOG: //CommonService.WriteLog<BasketItemEntity>(entity, " Created BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert); ExternalDomainBroker.CreateLog(" Created BaksetItem " , BizEntity.Common.BizLogType.Purchase_Basket_Insert , basketInfo.ItemSysNo.Value , basketInfo.CompanyCode); } else { basketInfo = BasketDA.UpdateBasketItem(basketInfo); //写LOG: //CommonService.WriteLog<BasketItemEntity>(entity, " Updated BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Update); ExternalDomainBroker.CreateLog(" Updated BaksetItem " , BizEntity.Common.BizLogType.Purchase_Basket_Update , basketInfo.ItemSysNo.Value , basketInfo.CompanyCode); } return(basketInfo); }
/// <summary> /// 创建采购篮商品(备货中心用) /// </summary> /// <param name="prepareInfo"></param> /// <returns></returns> public virtual BasketItemsInfo CreateBasketItemForPrepare(BasketItemsInfo prepareInfo) { if (BasketDA.CheckProductHasExistInBasket(prepareInfo) && !prepareInfo.ItemSysNo.HasValue) { //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库 //{0}:该商品已存在于采购篮中! throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), prepareInfo.ProductID)); } prepareInfo.LastVendorSysNo = BasketDA.GetVendorSysNoByProductNoAndStockSysNo(prepareInfo.ProductSysNo.Value, prepareInfo.StockSysNo.Value); #region [Check 实体逻辑] if (!prepareInfo.Quantity.HasValue || prepareInfo.Quantity == 0) { //{0}:该商品数量不能为空! throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), prepareInfo.ProductID)); } if (!prepareInfo.OrderPrice.HasValue) { //{0}:该商品结算价不能为空! throw new BizException(string.Format(GetMessageString("Basket_SettlePriceEmpty"), prepareInfo.ProductID)); } if (!prepareInfo.ProductSysNo.HasValue || prepareInfo.ProductSysNo == 0) { //{0}:该商品编号不能为空! throw new BizException(string.Format(GetMessageString("Basket_ItemSysNoEmpty"), prepareInfo.ProductID)); } else if (BasketDA.CheckProductHasExistInBasket(prepareInfo) && !prepareInfo.ItemSysNo.HasValue) { //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库 //{0}:该商品已存在于采购篮中! throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), prepareInfo.ProductID)); } #endregion //新建操作: prepareInfo = BasketDA.CreateBasketItemForPrepare(prepareInfo); //写LOG: // CommonService.WriteLog<BasketItemEntity>(entity, " Created BaksetItem For Prepare ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert); ExternalDomainBroker.CreateLog(" Created BaksetItem For Prepare " , BizEntity.Common.BizLogType.Purchase_Basket_Insert , prepareInfo.ItemSysNo.Value , prepareInfo.CompanyCode); return(prepareInfo); }
/// <summary> /// 审核拒绝并退回成本变价单信息 /// </summary> /// <param name="costChangeInfo"></param> /// <returns></returns> public virtual CostChangeInfo RefuseCostChange(CostChangeInfo costChangeInfo) { using (TransactionScope ts = new TransactionScope()) { costChangeInfo.CostChangeBasicInfo.Status = CostChangeStatus.Created; costChangeInfo = CostChangeDA.UpdateCostChangeAuditStatus(costChangeInfo); //记录日志 ExternalDomainBroker.CreateLog("Refuse CostChange" , BizEntity.Common.BizLogType.CostChange_Refuse , costChangeInfo.SysNo.Value, costChangeInfo.CompanyCode); ts.Complete(); } return(costChangeInfo); }
/// <summary> /// 审核代销商品规则 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual ConsignSettlementRulesInfo AuditConsignSettlementRule(ConsignSettlementRulesInfo info) { ConsignSettlementRulesInfo entity = ConsignSettlementRuleDA.GetConsignSettleRuleByCode(info.SettleRulesCode); if (entity == null) { //规则({0})不存在,无法审核 throw new BizException(string.Format(GetExceptionString("ConsignRule_RuleNotExist_Audit"), info.SettleRulesCode)); } if (entity.Status != ConsignSettleRuleStatus.Wait_Audit) { //规则({0})不是待审核状态,无法审核 throw new BizException(string.Format(GetExceptionString("ConsignRule_WaitingAudit_Invalid_Audit"), info.SettleRulesCode)); } ////审核人和创建人不能相同 //if (info.EditUser == entity.CreateUser) //{ // throw new BizException(GetExceptionString("ConsignRule_CreateAndAuditUserNotTheSame")); //} //检测商品的属性 CheckProduct(entity.ProductSysNo.Value); //时间段重复性的检测 CheckRuleDateRepeat(entity); entity.Status = ConsignSettleRuleStatus.Available; entity.EditUser = ExternalDomainBroker.GetUserNameByUserSysNo(ServiceContext.Current.UserSysNo); entity = Modify(entity, ConsignSettleRuleActionType.Audit); //发送ESB消息 EventPublisher.Publish <SettlementRuleAuditMessage>(new SettlementRuleAuditMessage() { AuditUserSysNo = ServiceContext.Current.UserSysNo, SettleRulesCode = entity.SettleRulesCode }); //记录系统日志 //WriteLog(entity, LogType.ConsignSettleRule_Audit); ExternalDomainBroker.CreateLog(" Audit ConsignSettleRule " , BizEntity.Common.BizLogType.ConsignSettleRule_Audit , entity.RuleSysNo.Value , entity.CompanyCode); return(entity); }
/// <summary> /// 修改供应商代收结算信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo UpdateGatherSettlement(GatherSettlementInfo info) { List <GatherSettlementItemInfo> deletetlist = GatherSettlementDA.GetSettleGatherItems(info); //获取已经存在的代收结算单基本信息: GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info); if (oldSettle.SettleStatus != GatherSettleStatus.ORG) { //该代收结算单不是待审核状态,不能进行删除操作! throw new BizException(GetMessageString("Gather_Orgin_Invalid")); } //获取已经存在的代收结算单Item信息: List <GatherSettlementItemInfo> oldlist = GatherSettlementDA.GetSettleGatherItems(info.SysNo.Value); if (deletetlist.Count >= oldlist.Count) { //不能全部删除代收结算单Item throw new BizException(GetMessageString("Gather_DeleteAllItems")); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //删除Item操作: foreach (GatherSettlementItemInfo item in deletetlist) { GatherSettlementDA.DeleteSettleItem(item, info.SysNo.Value); } //修改主表信息: info = GatherSettlementDA.UpdateGatherSettlement(info); //写LOG: //CommonService.WriteLog<VendorSettleGatherEntity>(entity, " Update Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" Update Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); scope.Complete(); return(info); } }
public CollectionPaymentInfo Abandon(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; entity.CreateUserSysNo = entity.CurrentUserSysNo; VerifyAbandon(entity); entity.Status = POCollectionPaymentSettleStatus.Abandon; //将代销转财务记录的状态修改为初始状态 foreach (var item in entity.SettleItems) { item.ConsignToAccLogInfo.ConsignToAccStatus = ConsignToAccountLogStatus.Origin; } entity.Note = string.Format("当前结算单已被{0}在{1}作废", "SysAdmin", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); using (TransactionScope scope = new TransactionScope()) { entity = this.CollectionPaymentDA.UpdateVendorSettleStatus(entity); //更新代销转财务记录状态 UpdateConsignToAccLogStatus(entity); //发送ESB消息 EventPublisher.Publish <CollectionPaymentAbandonMessage>(new CollectionPaymentAbandonMessage() { CurrentUserSysNo = ServiceContext.Current.UserSysNo, SysNo = entity.SysNo.Value }); scope.Complete(); } entity.OperationIP = OperationIP; entity.OperationUserSysNumber = OperationUserSysNumber; entity.OperationUserUniqueName = OperationUserUniqueName; //CommonService.WriteLog<CollectionPaymentEntity>(entity, " Abandon CollectionPayment ", entity.SysNo.Value.ToString(), (int)LogType.CollectionPayment_Abandon); ExternalDomainBroker.CreateLog(" Abandon CollectionPayment " , BizEntity.Common.BizLogType.POC_VendorSettle_Abandon , entity.SysNo.Value , entity.CompanyCode); return(entity); }
/// <summary> /// 虚库采购单 - 创建 /// </summary> /// <param name="vspoInfo"></param> /// <returns></returns> public virtual VirtualStockPurchaseOrderInfo CreateVSPO(VirtualStockPurchaseOrderInfo vspoInfo) { //验证 vspoInfo.PurchaseQty = 1; vspoInfo.Status = VirtualPurchaseOrderStatus.Normal; //初始状态 vspoInfo.CreateTime = DateTime.Now; vspoInfo.InStockOrderType = VirtualPurchaseInStockOrderType.PO; if (vspoInfo.SOItemSysNo == null || !vspoInfo.SOItemSysNo.HasValue) { //销售单Item编号不能为空! throw new BizException(GetMessageString("VSPO_ItemSysNoEmpty")); } //不能再生成虚库商品采购单 int i = VSPurchaseOrderDA.CalcVSPOQuantity(vspoInfo.SOItemSysNo.Value); if (i <= 0) { //不能再生成虚库商品采购单 throw new BizException(GetMessageString("VSPO_CannotCreateVSPO")); } for (int j = 1; j <= i; j++) { //生成虚库采购单 vspoInfo.SysNo = VSPurchaseOrderDA.CreateVSPO(vspoInfo).SysNo; //写LOG: CommonService.WriteLog<VSPOEntity>(entity, " created VSPO ", entity.SysNo.Value.ToString(), (int)LogType.St_SOVirtualItemRequest_Add); ExternalDomainBroker.CreateLog(" created VSPO " , BizEntity.Common.BizLogType.St_SOVirtualItemRequest_Add , vspoInfo.SysNo.Value , vspoInfo.CompanyCode); } //邮件发送 SendEmailWhenCreate(vspoInfo); //调用Order接口,生成虚库采购单后将对应的订单标识为备货状态 ExternalDomainBroker.UpdateSOCheckShipping(vspoInfo.SOSysNo.Value, VirtualPurchaseOrderStatus.Close); return(vspoInfo); }
/// <summary> /// 创建代销商品规则 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual ConsignSettlementRulesInfo CreateConsignSettlementRule(ConsignSettlementRulesInfo entity) { //检测数据完整性 CheckEntity(entity); //Code的重复性检测 ConsignSettlementRulesInfo chkEntity = ConsignSettlementRuleDA.GetConsignSettleRuleByCode(entity.SettleRulesCode); if (chkEntity != null) { //规则编码({0})已存在,请重新设置 throw new BizException(string.Format(GetExceptionString("ConsignRule_RuleExist"), entity.SettleRulesCode)); } //检测商品的属性 CheckProduct(entity.ProductSysNo.Value); //时间段重复性的检测 CheckRuleDateRepeat(entity); entity.Status = ConsignSettleRuleStatus.Wait_Audit; SetDefaultValue(entity); int sysNo = ConsignSettlementRuleDA.CreateConsignSettlementRule(entity); entity.RuleSysNo = sysNo; //发送ESB消息 EventPublisher.Publish <SettlementRuleCreateMessage>(new SettlementRuleCreateMessage() { CreateUserSysNo = ServiceContext.Current.UserSysNo, SettleRulesCode = entity.SettleRulesCode }); //记录系统日志 //WriteLog(entity, LogType.ConsignSettleRule_Create); ExternalDomainBroker.CreateLog(" Create ConsignSettle " , BizEntity.Common.BizLogType.ConsignSettleRule_Create , sysNo , entity.CompanyCode); return(entity); }
/// <summary> /// 创建供应商代收结算信息(人工创建) /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo CreateGatherSettlement(GatherSettlementInfo info) { info.GatherSettlementItemInfoList = GetAllSettleGatherItems(info); //验证仓库号 : if (null != info.GatherSettlementItemInfoList && 0 < info.GatherSettlementItemInfoList.Count) { foreach (var item in info.GatherSettlementItemInfoList) { //if (item.SettleType != GatherSettleType.RO_Adjust //&& item.StockSysNo != info.SourceStockInfo.SysNo.Value) if (item.StockSysNo != info.SourceStockInfo.SysNo.Value) { //单据号为{0}的{1}单,仓库号和代收单仓库不一致! throw new BizException(string.Format(GetMessageString("Gather_StockNotTheSame"), item.OrderSysNo, item.SettleType.ToString())); } } } ///创建操作: info.SettleStatus = GatherSettleStatus.ORG; using (TransactionScope ts = new TransactionScope()) { info.TotalAmt = info.GatherSettlementItemInfoList.Sum(i => (i.SalePrice * i.ProductQuantity) + (i.PromotionDiscount.HasValue?i.PromotionDiscount.Value:0)); GatherSettlementDA.CreateGatherSettlement(info); //发送创建Message EventPublisher.Publish(new CreateGatherSettlementMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写日志: CommonService.WriteLog<VendorSettleGatherEntity>(entity, " Create Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" Create Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); ts.Complete(); } return(info); }
/// <summary> /// 代收结算单 - 作废 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo AbandonGatherSettlement(GatherSettlementInfo info) { info.SettleStatus = GatherSettleStatus.ABD; GatherSettlementDA.UpdateGatherSettlementStatus(info, false); //发送作废Message EventPublisher.Publish(new GatherSettlementAbandonedMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写LOG;CommonService.WriteLog<VendorSettleGatherEntity>(entity, " Abandon Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" Abandon Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 虚库采购单 - 更新CS备注 /// </summary> /// <param name="vspoInfo"></param> /// <returns></returns> public virtual VirtualStockPurchaseOrderInfo UpdateCSMemoForVSPO(VirtualStockPurchaseOrderInfo vspoInfo) { #region [Check实体逻辑] if (!vspoInfo.SysNo.HasValue) { //虚库采购单的编号不能为空 throw new BizException(GetMessageString("VSPO_VSPOSysNoEmpty")); } //CS备注不能为空 if (vspoInfo.CSMemo == null || vspoInfo.CSMemo.Trim() == string.Empty) { //CS备注不能为空 throw new BizException(GetMessageString("VSPO_CSMemoEmpty")); } VirtualStockPurchaseOrderInfo localEntity = VSPurchaseOrderDA.LoadVSPO(vspoInfo.SysNo.Value); if (localEntity == null) { //该虚库采购单在数据中不存在,操作失败 throw new BizException(GetMessageString("VSPO_VSPONotFound")); } #endregion //更新操作: localEntity.CSMemo = vspoInfo.CSMemo; VSPurchaseOrderDA.UpdateVSPO(localEntity); //邮件发送: SendEmailWhenUpdate(PurchaseOrderOperationType.UpDateCSMemo, vspoInfo); //写LOG:CommonService.WriteLog<VSPOEntity>(entity, " updated CSMemo for VSPO ", entity.SysNo.Value.ToString(), (int)LogType.St_SOVirtualItemRequest_UpdateCSMemo); ExternalDomainBroker.CreateLog(" Updated CSMemo for VSPO " , BizEntity.Common.BizLogType.St_SOVirtualItemRequest_UpdateCSMemo , vspoInfo.SysNo.Value , vspoInfo.CompanyCode); return(vspoInfo); }
/// <summary> /// 更新代销商品规则 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual ConsignSettlementRulesInfo UpdateConsignSettlementRule(ConsignSettlementRulesInfo entity) { //检测数据完整性 CheckEntity(entity); //查询原实体 ConsignSettlementRulesInfo oldEntity = ConsignSettlementRuleDA.GetConsignSettleRuleByCode(entity.SettleRulesCode); if (oldEntity == null) { //规则({0})不存在,无法修改 throw new BizException(string.Format(GetExceptionString("ConsignRule_RuleNotExist"), entity.SettleRulesCode)); } if (oldEntity.Status != ConsignSettleRuleStatus.Wait_Audit) { //规则({0})不处于待审核状态,无法修改 throw new BizException(string.Format(GetExceptionString("ConsignRule_WaitingAudit_Invalid"), entity.SettleRulesCode)); } //检测商品的属性 CheckProduct(entity.ProductSysNo.Value); //时间段重复性的检测 CheckRuleDateRepeat(entity); SetDefaultValue(entity); entity.EditUser = ExternalDomainBroker.GetUserNameByUserSysNo(ServiceContext.Current.UserSysNo); entity = Modify(entity, ConsignSettleRuleActionType.Update); //记录系统日志 //WriteLog(entity, LogType.ConsignSettleRule_Update); ExternalDomainBroker.CreateLog(" Updated ConsignSettleRule " , BizEntity.Common.BizLogType.ConsignSettleRule_Update , entity.RuleSysNo.Value , entity.CompanyCode); return(entity); }
/// <summary> /// 更新成本变价单信息 /// </summary> /// <param name="costChangeInfo"></param> /// <returns></returns> public virtual CostChangeInfo UpdateCostChange(CostChangeInfo costChangeInfo) { #region [Check更新实体逻辑] //VerifyCreate(costChangeInfo); #endregion [Check更新实体逻辑] List <CostChangeItemsInfo> deleteList = new List <CostChangeItemsInfo>(); decimal totalDiffAmt = 0; using (TransactionScope ts = new TransactionScope()) { deleteList = costChangeInfo.CostChangeItems.Where(item => item.ItemActionStatus == ItemActionStatus.Delete).ToList(); if (deleteList.Count > 0) { deleteList.ForEach(delegate(CostChangeItemsInfo deleteItemInfo) { // 删除Item: CostChangeDA.DeleteCostChangeItems(deleteItemInfo); //将删除的Item从List中去掉: costChangeInfo.CostChangeItems.Remove(deleteItemInfo); }); } costChangeInfo.CostChangeItems.ForEach(delegate(CostChangeItemsInfo ItemInfo) { totalDiffAmt += (ItemInfo.NewPrice - ItemInfo.OldPrice) * ItemInfo.ChangeCount; }); costChangeInfo.CostChangeBasicInfo.EditUser = ServiceContext.Current.UserSysNo; costChangeInfo.CostChangeBasicInfo.TotalDiffAmt = totalDiffAmt; costChangeInfo = CostChangeDA.UpdateCostChange(costChangeInfo); //记录日志 ExternalDomainBroker.CreateLog("Update CostChange" , BizEntity.Common.BizLogType.CostChange_Update , costChangeInfo.SysNo.Value, costChangeInfo.CompanyCode); ts.Complete(); } return(costChangeInfo); }
/// <summary> /// 代收结算单 - 取消结算 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo CancelSettleGatherSettlement(GatherSettlementInfo info) { //1 检查当前结算单状态 if (info.SettleStatus != GatherSettleStatus.SET) { //当前结算单的状态不为已结算状态! throw new BizException(GetMessageString("Gather_Settle_Invalid")); } ////2 检查付款单是否作废,如果付款单未作废抛出异常(调用Invoice接口) if (!ExternalDomainBroker.IsAbandonGatherPayItem(info.SysNo.Value)) { throw new BizException(GetMessageString("Gather_Settle_Abandon_CancelSettle")); } GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info); if (info.SettleStatus != GatherSettleStatus.SET) { //该结算单不是已结算状态,不能进行取消结算操作! throw new BizException(GetMessageString("Gather_Settle_Invalid_CancelSettle")); } info.SettleStatus = GatherSettleStatus.AUD; GatherSettlementDA.UpdateGatherSettlementStatus(info, false); //发送取消结算Message EventPublisher.Publish(new GatherSettlementSettleCanceledMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写LOG:CommonService.WriteLog<VendorSettleGatherEntity>(entity, " CancelSettled Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" CancelSettled Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 代收结算单 - 结算 /// </summary> /// <param name="info"></param> /// <returns></returns> public GatherSettlementInfo SettleGatherSettlement(GatherSettlementInfo info) { info.SettleStatus = GatherSettleStatus.SET; GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info); if (oldSettle.SettleStatus != GatherSettleStatus.AUD) { //该结算单不是已审核状态,不能进行结算操作! throw new BizException(GetMessageString("Gather_Audited_Invalid_Settle")); } GatherSettlementDA.UpdateGatherSettlementSettleStatus(info); //调用Invoice接口,创建PayItem: ExternalDomainBroker.CreatePayItem( new PayItemInfo() { OrderSysNo = info.SysNo.Value, PayAmt = info.TotalAmt, OrderType = PayableOrderType.CollectionSettlement, PayStyle = PayItemStyle.Normal }); //发送结算Message EventPublisher.Publish(new GatherSettlementSettledMessage() { SettlementSysNo = info.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); //写Log: //CommonService.WriteLog<VendorSettleGatherEntity>(entity, " Settle Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock); ExternalDomainBroker.CreateLog(" Settle Gather " , BizEntity.Common.BizLogType.Purchase_Verify_InStock , info.SysNo.Value , info.CompanyCode); return(info); }
/// <summary> /// 审核 /// </summary> /// <param name="entity"></param> /// <returns></returns> public CollectionPaymentInfo Audit(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; entity.AuditUserSysNo = entity.CurrentUserSysNo; //entity.AuditUserSysNo = SystemUserHelper.GetUserSystemNumber(BusinessContext.Current.OperationUserFullName, // BusinessContext.Current.OperationUserSourceDirectoryKey, BusinessContext.Current.OperationUserLoginName, // BusinessContext.Current.CompanyCode); //entity.AuditUserSysNo = 3256; VerifyAudite(entity); VerifyProductPMSysNo(entity); entity.AuditTime = DateTime.Now; entity.Status = POCollectionPaymentSettleStatus.Audited; entity = CollectionPaymentDA.UpdateVendorSettleStatus(entity); //发送ESB消息 EventPublisher.Publish <CollectionPaymentAuditMessage>(new CollectionPaymentAuditMessage() { CurrentUserSysNo = ServiceContext.Current.UserSysNo, SysNo = entity.SysNo.Value }); entity.OperationIP = OperationIP; entity.OperationUserSysNumber = OperationUserSysNumber; entity.OperationUserUniqueName = OperationUserUniqueName; //CommonService.WriteLog<CollectionPaymentEntity>(entity, " Audit CollectionPayment ", entity.SysNo.Value.ToString(), (int)LogType.CollectionPayment_Audit); ExternalDomainBroker.CreateLog(" Audit CollectionPayment " , BizEntity.Common.BizLogType.POC_VendorSettle_Audit , entity.SysNo.Value , entity.CompanyCode); return(entity); }
public CollectionPaymentInfo CancelAbandon(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; entity.CreateUserSysNo = entity.CreateUserSysNo; VerifyCancelAbandon(entity); entity.Status = POCollectionPaymentSettleStatus.Origin; //将代收代付转财务记录的状态修改为人工已建 foreach (var item in entity.SettleItems) { item.ConsignToAccLogInfo.ConsignToAccStatus = ConsignToAccountLogStatus.ManualCreated; } using (TransactionScope scope = new TransactionScope()) { entity = CollectionPaymentDA.UpdateVendorSettleStatus(entity); //更新代销转财务记录状态 UpdateConsignToAccLogStatus(entity); scope.Complete(); } entity.OperationIP = OperationIP; entity.OperationUserSysNumber = OperationUserSysNumber; entity.OperationUserUniqueName = OperationUserUniqueName; ExternalDomainBroker.CreateLog(" Abandon Cancel CollectionPayment " , BizEntity.Common.BizLogType.POC_VendorSettle_Abandon , entity.SysNo.Value , entity.CompanyCode); return(entity); }
/// <summary> /// 作废代销商品规则 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual ConsignSettlementRulesInfo AbandonConsignSettlementRule(string settleRulesCode) { ConsignSettlementRulesInfo entity = ConsignSettlementRuleDA.GetConsignSettleRuleByCode(settleRulesCode); if (entity == null) { //规则({0})不存在,无法作废 throw new BizException(string.Format(GetExceptionString("ConsignRule_RuleNotExist_Abandon"), settleRulesCode)); } if (entity.Status != ConsignSettleRuleStatus.Wait_Audit) { //规则({0})不处于待审核状态,无法作废 throw new BizException(string.Format(GetExceptionString("ConsignRule_WaitingAudit_Invalid_Abandon"), settleRulesCode)); } entity.Status = ConsignSettleRuleStatus.Forbid; entity.EditUser = ExternalDomainBroker.GetUserNameByUserSysNo(ServiceContext.Current.UserSysNo); entity = Modify(entity, ConsignSettleRuleActionType.Abandon); //发送ESB消息 EventPublisher.Publish <SettlementRuleAbandonMessage>(new SettlementRuleAbandonMessage() { AbandonUserSysNo = ServiceContext.Current.UserSysNo, SettleRulesCode = settleRulesCode }); //记录系统日志 // WriteLog(entity, LogType.ConsignSettleRule_Abadon); ExternalDomainBroker.CreateLog(" Abandon ConsignSettleRule " , BizEntity.Common.BizLogType.ConsignSettleRule_Abadon , entity.RuleSysNo.Value , entity.CompanyCode); return(entity); }
public CollectionPaymentInfo Update(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; VerifyUpdate(entity); VerifySettleItems(entity, SettlementVerifyType.UPDATE); VerifyProductPMSysNo(entity); VerityOverConsignRuleQuantity(entity); List <CollectionPaymentItem> list = new List <CollectionPaymentItem>(); using (TransactionScope scope = new TransactionScope()) { //1 删除需要delete的item foreach (CollectionPaymentItem item in entity.SettleItems) { if (item.SettleSysNo.HasValue && item.SettleSysNo == -1) { list.Add(item); } } if (list.Count > 0) { foreach (CollectionPaymentItem item in list) { //将需要删除的Item对应的Acclog状态改为[初始状态:0] //VendorDA.UpdateConsignToAccountLogStatus(item.ConsignToAccLogInfo.LogSysNo.Value, ConsignToAccountLogStatus.Origin); this.ConsignSettlementDA.UpdateConsignToAccountLogStatus( item.ConsignToAccLogInfo.LogSysNo.Value, ConsignToAccountLogStatus.Origin); CollectionPaymentDA.DeleteSettleItem(item); entity.SettleItems.Remove(item); } } //将所有选中的SettleItem状态改为[人工已建:4] var validItems = entity.SettleItems.Except(list); foreach (var item in validItems) { //如果item的sysno没有值,则表示是新增加的item,需要更新对应的ConfignToAcclog if (!item.ItemSysNo.HasValue) { item.ConsignToAccLogInfo.ConsignToAccStatus = ConsignToAccountLogStatus.ManualCreated; this.ConsignSettlementDA.UpdateConsignToAccountLogStatus(item.ConsignToAccLogInfo.LogSysNo.Value, ConsignToAccountLogStatus.ManualCreated); } } //2 更新结算单 CollectionPaymentDA.Update(entity); scope.Complete(); } //3 记录删除的items foreach (CollectionPaymentItem item in list) { if (item.ItemSysNo.HasValue) { item.OperationIP = OperationIP; item.OperationUserSysNumber = OperationUserSysNumber; item.OperationUserUniqueName = OperationUserUniqueName; //CommonService.WriteLog<CollectionPaymentItem>(item, " Deleted CollectionPaymentItem ", item.SysNo.Value.ToString(), (int)LogType.CollectionPayment_Item_Delete); ExternalDomainBroker.CreateLog(" Deleted CollectionPaymentItem " , BizEntity.Common.BizLogType.POC_VendorSettle_Item_Delete , item.ItemSysNo.Value , entity.CompanyCode); } } //4 记录修改的items foreach (CollectionPaymentItem item in entity.SettleItems) { if (item.ItemSysNo.HasValue) { item.OperationIP = OperationIP; item.OperationUserSysNumber = OperationUserSysNumber; item.OperationUserUniqueName = OperationUserUniqueName; //CommonService.WriteLog<CollectionPaymentItem>(item, " Updated CollectionPaymentSettleItem ", item.SysNo.Value.ToString(), (int)LogType.CollectionPayment_Item_Update); ExternalDomainBroker.CreateLog(" Updated CollectionPaymentSettleItem " , BizEntity.Common.BizLogType.POC_VendorSettle_Item_Update , item.ItemSysNo.Value , entity.CompanyCode); } } return(entity); }
/// <summary> /// 验证导入的采购篮数据是否合法并创建采购篮 /// </summary> /// <param name="itemList"></param> /// <returns></returns> public virtual List <BasketItemsInfo> BatchImportAndCreateBasketItem(List <BasketItemsInfo> itemList, bool isThrowException) { if (null == itemList || 0 == itemList.Count) { //没有需要导入的数据 throw new BizException(GetMessageString("Basket_NoDataImport")); } foreach (var entity in itemList) { #region [Check实体逻辑] if (!entity.LastVendorSysNo.HasValue) { //供应商编号无效 entity.ErrorMessage += GetMessageString("Basket_VendorSysNoInvalid"); if (isThrowException) { throw new BizException(GetMessageString("Basket_VendorSysNoInvalid")); } } var vendor = VendorDA.LoadVendorInfo(entity.LastVendorSysNo.Value); if (vendor == null) { //供应商无效 entity.ErrorMessage += GetMessageString("Basket_VendorInvalid"); if (isThrowException) { throw new BizException(GetMessageString("Basket_VendorInvalid")); } } else { entity.CompanyCode = vendor.CompanyCode; entity.VendorSysNo = vendor.SysNo.Value; } if (!entity.Quantity.HasValue || entity.Quantity == 0) { //{0}:该商品数量不能为空! entity.ErrorMessage += string.Format(GetMessageString("Basket_ProductQtyEmpty"), entity.ProductID); if (isThrowException) { throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), entity.ProductID)); } } if (!entity.OrderPrice.HasValue) { //采购价格为空 entity.ErrorMessage += GetMessageString("Basket_PurchasePriceEmpty"); if (isThrowException) { throw new BizException(GetMessageString("Basket_PurchasePriceEmpty")); } } entity.ProductSysNo = BasketDA.GetItemSysNoByItemID(entity.ProductID, entity.CompanyCode); if (!entity.ProductSysNo.HasValue || entity.ProductSysNo == 0) { entity.ErrorMessage += GetMessageString("Basket_ProductSysNoInvalid"); if (isThrowException) { throw new BizException(GetMessageString("Basket_ProductSysNoInvalid")); } } entity.StockSysNo = BasketDA.GetStockSysNoByName(entity.StockName, entity.CompanyCode); if (!entity.StockSysNo.HasValue || entity.StockSysNo == 0) { entity.ErrorMessage += GetMessageString("Basket_StocknameInvalid"); if (isThrowException) { throw new BizException(GetMessageString("Basket_StocknameInvalid")); } } if (BasketDA.CheckProductHasExistInBasket(entity) && !entity.ItemSysNo.HasValue) { //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库 //{0}:该商品已存在于采购篮中! entity.ErrorMessage += string.Format(GetMessageString("Basket_ItemExists"), entity.ProductID); if (isThrowException) { throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), entity.ProductID)); } } #endregion if (string.IsNullOrEmpty(entity.ErrorMessage)) { entity.ReadyQuantity = 0; var resultEntity = BasketDA.CreateBasketItemForPrepare(entity); //写LOG: //CommonService.WriteLog<BasketItemEntity>(entity, " Batch Created BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert); ExternalDomainBroker.CreateLog(" Batch Created BaksetItem " , BizEntity.Common.BizLogType.Purchase_Basket_Insert , entity.ItemSysNo.Value , entity.CompanyCode); } } return(itemList); }
public CollectionPaymentInfo CancelSettled(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; entity.SettleUserSysNo = entity.CurrentUserSysNo; VerifyCancelSettled(entity); //entity.SettleUserSysNo = SystemUserHelper.GetUserSystemNumber(BusinessContext.Current.OperationUserFullName, //BusinessContext.Current.OperationUserSourceDirectoryKey, BusinessContext.Current.OperationUserLoginName, //BusinessContext.Current.CompanyCode); //1 将所有以结算的财务单设置为ManualCreated状态 //VendorSettleDAL dal = new VendorSettleDAL(); //统计规则 List <ConsignSettlementRulesInfo> quantityCountList = CollectionPaymentDA.GetSettleRuleQuantityCount(entity.SysNo.Value); foreach (var quantityCount in quantityCountList) { //规则状态到结算这一步,一定会是已生效或者是已过期,还包括已终止,其他的一律视为异常 if (quantityCount.Status != ConsignSettleRuleStatus.Disable && quantityCount.Status != ConsignSettleRuleStatus.Enable && quantityCount.Status != ConsignSettleRuleStatus.Stop) { throw new BizException(string.Format(GetMessageString("Consign_Check_InvalidConsignSettleRule"), quantityCount.SettleRulesName)); } } using (TransactionScope scope = new TransactionScope()) { #region 结算规则操作 foreach (var quantityCount in quantityCountList) { //计算结算数量 quantityCount.SettledQuantity -= quantityCount.SubmitSettleQuantity; //修改规则状态 switch (quantityCount.Status) { case ConsignSettleRuleStatus.Enable: quantityCount.IsNeedUpdateStatus = true; break; case ConsignSettleRuleStatus.Disable: quantityCount.IsNeedUpdateStatus = true; quantityCount.Status = ConsignSettleRuleStatus.Enable; break; case ConsignSettleRuleStatus.Stop: //已终止状态将不在处理 break; default: break; } if (quantityCount.SettledQuantity.Value == 0) { //刚好使用到的规则的商品数量为0,证明只有该数据使用规则,将其变成以未生效状态 quantityCount.Status = ConsignSettleRuleStatus.Available; } if (quantityCount.IsNeedUpdateStatus) { //修改结算规则状态为已生效 ObjectFactory <IConsignSettlementDA> .Instance.UpdateConsignSettleRuleStatusAndQuantity(quantityCount.RuleSysNo.Value, quantityCount.Status.Value, quantityCount.SettledQuantity.Value); } } #endregion foreach (CollectionPaymentItem item in entity.SettleItems) { item.ConsignToAccLogInfo.ConsignToAccStatus = ConsignToAccountLogStatus.ManualCreated; item.ConsignToAccLogInfo.Cost = 0; item.ConsignToAccLogInfo.FoldCost = null; ConsignSettlementDA.CancelSettleConsignToAccountLog(item.ConsignToAccLogInfo.LogSysNo.Value); } //2 修改结算单的状态 entity.SettleTime = DateTime.Now; entity.Status = POCollectionPaymentSettleStatus.Audited; entity.AuditUserSysNo = entity.CurrentUserSysNo; entity = this.CollectionPaymentDA.UpdateVendorSettleStatus(entity); //发送ESB消息 EventPublisher.Publish <CollectionPaymentCancelSettlementMessage>(new CollectionPaymentCancelSettlementMessage() { CurrentUserSysNo = ServiceContext.Current.UserSysNo, SysNo = entity.SysNo.Value }); scope.Complete(); } ExternalDomainBroker.CreateLog(" CancelSettled VendorSettle " , BizEntity.Common.BizLogType.POC_VendorSettle_CancelSettle , entity.SysNo.Value , entity.CompanyCode); //记录规则更新日志 foreach (var qLog in quantityCountList.Where(p => p.IsNeedUpdateStatus)) { ExternalDomainBroker.CreateLog("CancelSettled VendorSettle Update SettleRule" , BizEntity.Common.BizLogType.ConsignSettleRule_Update , qLog.RuleSysNo.Value , qLog.CompanyCode); } return(entity); }
public CollectionPaymentInfo Settle(CollectionPaymentInfo entity) { string OperationIP = entity.OperationIP; int? OperationUserSysNumber = entity.OperationUserSysNumber; string OperationUserUniqueName = entity.OperationUserUniqueName; entity.SettleUserSysNo = entity.CurrentUserSysNo; VerifySettle(entity); this.VerifySettleItems(entity, SettlementVerifyType.SETTLE); //entity.SettleUserSysNo = SystemUserHelper.GetUserSystemNumber(BusinessContext.Current.OperationUserFullName, // BusinessContext.Current.OperationUserSourceDirectoryKey, BusinessContext.Current.OperationUserLoginName, // BusinessContext.Current.CompanyCode); //CollVendorSettleDAL dal = collVendorSettleDAL; //entity.CreateUserSysNo = 3256; //统计规则 string text = string.Empty; List <ConsignSettlementRulesInfo> ruleList = CollectionPaymentDA.GetSettleRuleQuantityCount(entity.SysNo.Value); foreach (var currentRule in ruleList) { //规则状态到结算这一步,一定会是已生效或者是未生效,其他的一律视为异常 if (currentRule.Status != ConsignSettleRuleStatus.Available && currentRule.Status != ConsignSettleRuleStatus.Enable) { //规则已经是无效状态,抛出异常 text = string.Format("无效的规则:{0}", currentRule.SettleRulesName); throw new BizException(text); } //超过结算数量 bool result = false; if (currentRule.SettleRulesQuantity.HasValue) { result = currentRule.SettleRulesQuantity.Value - (currentRule.SettledQuantity ?? 0) - (currentRule.SubmitSettleQuantity ?? 0) < 0; } if (result) { //超过结算数量,抛出异常 throw new BizException(string.Format(GetMessageString("Consign_Check_MoreThanSettleRuleQuantity"), currentRule.SettleRulesName)); } } using (TransactionScope scope = new TransactionScope()) { #region 结算规则操作 foreach (var quantityCount in ruleList) { quantityCount.SettledQuantity = quantityCount.SettledQuantity.Value + quantityCount.SubmitSettleQuantity; //修改规则状态 if (quantityCount.Status == ConsignSettleRuleStatus.Available) { quantityCount.Status = ConsignSettleRuleStatus.Enable; } //如果数量为0了,将修改状态为已过期 if (quantityCount.SettleRulesQuantity.HasValue && quantityCount.SettleRulesQuantity.Value == (quantityCount.SettledQuantity ?? 0)) { quantityCount.Status = ConsignSettleRuleStatus.Disable; quantityCount.SettledQuantity = quantityCount.SettleRulesQuantity; } //修改结算规则状态为已生效 ObjectFactory <IConsignSettlementDA> .Instance.UpdateConsignSettleRuleStatusAndQuantity(quantityCount.RuleSysNo.Value, quantityCount.Status.Value, quantityCount.SettledQuantity.Value); } #endregion //更改每个item的财务记录为最终结算 foreach (CollectionPaymentItem item in entity.SettleItems) { if (ConsignToAccountLogStatus.Settled == item.ConsignToAccLogInfo.ConsignToAccStatus.Value) { //当前商品的代销转财务记录(记录号:{0})的状态已经为“已结算”状态! throw new BizException(string.Format(GetMessageString("Consign_AccStatus_Settled_Check"), item.ConsignToAccLogInfo.ConsignToAccStatus.Value)); } if (item.Cost < 0) { //当前商品(商品系统编号:{0})的结算金额小于0! throw new BizException(string.Format(GetMessageString("Consign_Products_SettleAmt_Check"), item.ConsignToAccLogInfo.ProductSysNo.Value)); } decimal foldCost = item.ConsignToAccLogInfo.CreateCost.Value - item.Cost; ConsignSettlementDA.SettleConsignToAccountLog(item.ConsignToAccLogInfo.LogSysNo.Value, item.Cost, foldCost); } //2 修改结算单的状态 entity.SettleTime = DateTime.Now; entity.Status = POCollectionPaymentSettleStatus.Settled; entity = this.CollectionPaymentDA.UpdateVendorSettleStatus(entity); //发送ESB消息 EventPublisher.Publish <CollectionPaymentSettlementMessage>(new CollectionPaymentSettlementMessage() { CurrentUserSysNo = ServiceContext.Current.UserSysNo, SysNo = entity.SysNo.Value }); scope.Complete(); } //结算商品期间过期状态判断 foreach (var quantityCount in ruleList) { if (quantityCount.Status == ConsignSettleRuleStatus.Enable) { //如果这期间的结算商品已经全部结算完毕,那么这个结算规则也无效,对于是否还有剩余将无效 ObjectFactory <IConsignSettlementDA> .Instance.UpdateExistsConsignSettleRuleItemStatus(quantityCount.RuleSysNo.Value); } } //3 生成结算单的付款单 //调用Invoice接口:生成结算单的付款单 ExternalDomainBroker.CreatePayItem(new PayItemInfo() { OrderSysNo = entity.SysNo.Value, PayAmt = entity.TotalAmt, OrderType = PayableOrderType.CollectionPayment, PayStyle = PayItemStyle.Normal }); ExternalDomainBroker.CreateLog(" Settled VendorSettle " , BizEntity.Common.BizLogType.POC_VendorSettle_Settle , entity.SysNo.Value , entity.CompanyCode); //记录规则更新日志 foreach (var qLog in ruleList) { ExternalDomainBroker.CreateLog("Settled VendorSettle Update SettleRule" , BizEntity.Common.BizLogType.ConsignSettleRule_Update , qLog.RuleSysNo.Value , qLog.CompanyCode); } return(entity); }