/// <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="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="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="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); }
/// <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); }
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); }
/// <summary> /// 检查PM信息 /// </summary> /// <param name="refundInfo"></param> public void CheckRefundPM(VendorRefundInfo refundInfo) { int userSysNo = refundInfo.PMUserSysNo.Value; //获取PM List: List <int> pmSysNo = VendorRefundDA.GetPMUserSysNoByRMAVendorRefundSysNo(refundInfo.SysNo.Value); //获得备份的PM: List <ProductManagerInfo> getPMList = ExternalDomainBroker.GetPMList(userSysNo).ProductManagerInfoList; List <int> userSysNoList = new List <int>(); foreach (var dr in getPMList) { userSysNoList.Add(dr.UserInfo.SysNo.Value); } userSysNoList.Add(userSysNo); foreach (var sysNo in pmSysNo) { bool temp = false; foreach (var pm in userSysNoList) { if (sysNo == pm) { temp = true; } } if (!temp) { //您不是当前产品的PM,也不是当前产品PM的备份PM,无法操作! throw new BizException(GetMessageString("VendorRefund_CannotOperate")); } } }
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); }
public CommissionMaster CreateSettleCommission(CommissionMaster req) { req = GetManualCommissionMaster(req, true); if (req.ItemList.Count == 0) { throw new BizException(GetMessageString("Commission_Error_NoItemData")); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { req.Status = VendorCommissionMasterStatus.SET; CommissionDA.InsertCommissionMaster(req); CommissionDA.InsertCommissionItems(req); #region Insert Detail foreach (var item in req.ItemList) { if (item.DetailList != null) { item.DetailList.ForEach(p => { p.CommissionItemSysNo = item.ItemSysNo; CommissionDA.InsertCommissionDetail(p, req.CompanyCode, VendorCommissionItemType.SAC); }); } if (item.DetailOrderList != null) { item.DetailOrderList.ForEach(p => { p.CommissionItemSysNo = item.ItemSysNo; p.SalePrice = item.OrderCommissionFee; p.PromotionDiscount = 0; if (p.ReferenceType == VendorCommissionReferenceType.RMA) { p.SalePrice = -p.SalePrice; } p.Quantity = null; CommissionDA.InsertCommissionDetail(p, req.CompanyCode, VendorCommissionItemType.SOC); }); } if (item.DetailDeliveryList != null) { item.DetailDeliveryList.ForEach(p => { p.CommissionItemSysNo = item.ItemSysNo; p.SalePrice = item.DeliveryFee; p.PromotionDiscount = 0; p.Quantity = null; CommissionDA.InsertCommissionDetail(p, req.CompanyCode, VendorCommissionItemType.DEF); }); } } #endregion #region CreatePayItem ExternalDomainBroker.CreatePayItem(new PayItemInfo() { OrderSysNo = req.SysNo.Value, PayAmt = -Math.Round(req.TotalAmt ?? 0, 2), OrderType = PayableOrderType.Commission, PayStyle = PayItemStyle.Normal, BatchNumber = 1, Note = GetMessageString("Commission_ManualNote") }); #endregion scope.Complete(); } return(req); }
/// <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); }
/// <summary> /// PMCC审核通过 /// </summary> /// <param name="refundInfo"></param> /// <returns></returns> public virtual VendorRefundInfo PMCCApproveVendorRefund(VendorRefundInfo refundInfo) { //编号不能为空 if (!refundInfo.SysNo.HasValue || refundInfo.SysNo.Value <= 0) { //供应商退款编号无效 throw new BizException(GetMessageString("VendorRefund_SysNoEmpty")); } VendorRefundInfo localEntity = VendorRefundDA.LoadVendorRefundInfo(refundInfo.SysNo.Value); if (localEntity == null) { //供应商退款单在数据中不存在 throw new BizException(GetMessageString("VendorRefund_RefundNotExist")); } if (localEntity.Status.Value == VendorRefundStatus.Abandon) { //该供应商退款单为作废状态,不允许进行当前操作! throw new BizException(GetMessageString("VendorRefund_Abandon_Invalid")); } if (localEntity.Status.Value == VendorRefundStatus.Origin) { //该供应商退款单为初始状态,不允许进行当前操作! throw new BizException(GetMessageString("VendorRefund_Origin_Invalid")); } if (localEntity.Status.Value == VendorRefundStatus.PMDVerify) { //该供应商退款单为PMD审核状态,不允许进行当前操作! throw new BizException(GetMessageString("VendorRefund_PMDVerify_Invalid")); } if (localEntity.Status.Value == VendorRefundStatus.PMCCVerify) { throw new BizException("该供应商退款单为PMCC审核状态,不允许进行当前操作!"); } //if (localEntity.CreateUserSysNo == ServiceContext.Current.UserSysNo) //{ // //供应商退款单中,创建人,PM审核人,PMD审核人,PMCC审核人,不能相同 // throw new BizException(GetMessageString("VendorRefund_OperatorCannotSame_Invalid")); //} localEntity.PMCCUserSysNo = ServiceContext.Current.UserSysNo; localEntity.PMCCAuditTime = System.DateTime.Now; localEntity.PMCCMemo = refundInfo.PMCCMemo; localEntity.Status = VendorRefundStatus.PMCCVerify; //加载当前商家退款单Items: List <VendorRefundItemInfo> localItem = VendorRefundDA.LoadVendorRefundItems(localEntity.SysNo.Value); #region 调用RMA接口:判断单件是否可以关闭 List <int> RegisterSysNo = new List <int>(); localItem.ForEach(a => RegisterSysNo.Add(a.RegisterSysNo.Value)); //调用RMA接口,判断单件是否可以关闭 List <RMARegisterInfo> getList = ExternalDomainBroker.GetRMARegisterList(RegisterSysNo); foreach (var item in getList) { if (item.BasicInfo.Status != RMARequestStatus.Handling) //RMARequestStatus.Handling 1 表示 处理中 { throw new BizException(string.Format(GetMessageString("VendorRefund_CloseInvalid"), item.SysNo.Value)); } } #endregion TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; List <VendorRefundItemInfo> list = new List <VendorRefundItemInfo>(); List <KeyValuePair <int, int> > registerList = new List <KeyValuePair <int, int> >(); List <VendorRefundInfo> deductOnVendor = new List <VendorRefundInfo>(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //更新状态 : localEntity = VendorRefundDA.UpdateVendorRefundInfo(localEntity); //关闭单件并扣减RMA库存中OnVendorQty数量: list = VendorRefundDA.LoadVendorRefundItems(localEntity.SysNo.Value); foreach (var item in list) { int registerNo = item.RegisterSysNo.Value; registerList.Add(new KeyValuePair <int, int>(registerNo, localEntity.PMDUserSysNo.Value)); ////调用RMA接口,根据单件号获取接收仓库: string[] str = ExternalDomainBroker.GetReceiveWarehouseByRegisterSysNo(registerNo); if (!string.IsNullOrEmpty(str[0]) && !string.IsNullOrEmpty(str[1])) { deductOnVendor.Add(new VendorRefundInfo { WarehouseSysNo = Convert.ToInt32(str[0]), ProductSysNo = Convert.ToInt32(str[1]), RegisterSysNo = registerNo }); } } ////调用RMA接口,关闭送修单: List <int> OutBound = ExternalDomainBroker.GetOutBoundSysNoListByRegisterSysNo(registerList.ToListString("Key")); ExternalDomainBroker.UpdateOutBound(OutBound.ToListString()); //发送ESB消息 EventPublisher.Publish <VendorRefundInfoAuditMessage>(new VendorRefundInfoAuditMessage() { AuditUserSysNo = ServiceContext.Current.UserSysNo, SysNo = refundInfo.SysNo.Value }); scope.Complete(); } ////调用RMA接口:关闭单件 List <int> registerSysNos = new List <int>(); registerList.ForEach(x => { registerSysNos.Add(x.Key); }); ExternalDomainBroker.BatchCloseRegisterForVendorRefund(registerSysNos); //扣减RMA库存中OnVendorQty数量 ExternalDomainBroker.BatchDeductOnVendorQty(deductOnVendor); ////调用Invoice接口,生成财务POR记录 PayableInfo payableInfo = new PayableInfo() { OrderSysNo = localEntity.SysNo.Value, CurrencySysNo = 1, OrderAmt = -1 * localEntity.RefundCashAmt.Value, PayStatus = 0, InvoiceStatus = 0, OrderType = PayableOrderType.RMAPOR, //9 InvoiceUpdateTime = DateTime.Parse("1900-1-1"), InvoiceFactStatus = PayableInvoiceFactStatus.Others // 3 }; PayableInfo createdPayableInfo = ExternalDomainBroker.CreatePayable(payableInfo); if (null != createdPayableInfo && 0 < createdPayableInfo.SysNo) { int financePaySysNo = createdPayableInfo.SysNo.Value; List <PayItemInfo> payItemList = new List <PayItemInfo>(); list.ForEach(x => { PayItemInfo item = new PayItemInfo() { PaySysNo = financePaySysNo, PayStyle = PayItemStyle.Normal, Status = PayItemStatus.Origin, PayAmt = x.RefundCash.HasValue ? (-1 * x.RefundCash.Value) : -999999, OrderType = PayableOrderType.RMAPOR, OrderSysNo = x.RefundSysNo.Value }; payItemList.Add(item); }); ExternalDomainBroker.BatchCreatePayItem(payItemList); } return(localEntity); }
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); }
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); }
/// <summary> /// 虚库采购单 - 更新 /// </summary> /// <param name="vspoInfo"></param> /// <returns></returns> public virtual VirtualStockPurchaseOrderInfo UpdateVSPO(VirtualStockPurchaseOrderInfo vspoInfo) { #region [Check实体逻辑] //单据号不能为空 if (!vspoInfo.InStockOrderSysNo.HasValue) { //单据号不能为空 throw new BizException(GetMessageString("VSPO_OrderSysNoEmpty")); } //请输入估计到达时间 if (!vspoInfo.EstimateArriveTime.HasValue) { //估计到达时间不能为空 throw new BizException(GetMessageString("VSPO_EATimeEmpty")); } //预计到货时间 -小时分 不能为空 if (vspoInfo.EstimateArriveTime.Value.ToShortTimeString() == "00:00" || vspoInfo.EstimateArriveTime.Value < Convert.ToDateTime("1900-01-01")) { throw new BizException(GetMessageString("VSPO_EATLongTimeEmpty")); } //请输入正确的10位移仓单号 if (vspoInfo.InStockOrderType.Value == VirtualPurchaseInStockOrderType.Shift && vspoInfo.InStockOrderSysNo.ToString().Length != 10) { //移仓单号格式不正确 throw new BizException(GetMessageString("VSPO_ShiftSysNoFormatWrong")); } //请输入正确的10位转换单号 if (vspoInfo.InStockOrderType.Value == VirtualPurchaseInStockOrderType.Convert && vspoInfo.InStockOrderSysNo.ToString().Length != 10) { //转换单号格式不正确 throw new BizException(GetMessageString("VSPO_ConvertSysNoFormatWrong")); } //请输入正确的小于8位采购单号 if (vspoInfo.InStockOrderType.Value == VirtualPurchaseInStockOrderType.PO && vspoInfo.InStockOrderSysNo.ToString().Length > 8) { //采购单号格式不正确 throw new BizException(GetMessageString("VSPO_POSysNoFormatWrong")); } #endregion //虚库采购单为作废状态,不能更新: VirtualStockPurchaseOrderInfo localEntiy = VSPurchaseOrderDA.LoadVSPO(vspoInfo.SysNo.Value); if (localEntiy.Status.HasValue && localEntiy.Status.Value == VirtualPurchaseOrderStatus.Abandon) { //虚库采购单为作废状态,不能更新! throw new BizException(GetMessageString("VSPO_AbandonVSPO_Invalid_Update")); } #region [根据入库单类型,检查单据状态 以及单据对应商品是否存在:] if (localEntiy.InStockOrderType.Value != VirtualPurchaseInStockOrderType.PO) { localEntiy.InStockOrderSysNo = Convert.ToInt32(localEntiy.InStockOrderSysNo.Value.ToString().Substring(2)); } //验证对应的PO中是否有对应的商品: if (localEntiy.InStockOrderType.Value == VirtualPurchaseInStockOrderType.PO) { if (!VSPurchaseOrderDA.ValidateFromPO(vspoInfo.SysNo.Value, Convert.ToInt32(vspoInfo.InStockOrderSysNo))) { //在您输入的采购单中找不到对应的商品或该采购单已经作废! throw new BizException(GetMessageString("VSPO_PONotFound")); } } if (localEntiy.InStockOrderType.Value == VirtualPurchaseInStockOrderType.Shift) { if (!VSPurchaseOrderDA.ValidateFromShift(vspoInfo.SysNo.Value, Convert.ToInt32(vspoInfo.InStockOrderSysNo))) { //在您输入的移仓单中找不到对应的商品或该移仓单已经作废! throw new BizException(GetMessageString("VSPO_ShiftNotFound")); } } if (localEntiy.InStockOrderType.Value == VirtualPurchaseInStockOrderType.Convert) { if (!VSPurchaseOrderDA.ValidateFromTransfer(vspoInfo.SysNo.Value, Convert.ToInt32(vspoInfo.InStockOrderSysNo))) { //在您输入的转换单中找不到对应的商品或该转换单已经作废! throw new BizException(GetMessageString("VSPO_ConvertNotFound")); } } #endregion TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { localEntiy.Status = VirtualPurchaseOrderStatus.Close; if (vspoInfo.PMMemo.Trim().Length > 0) { localEntiy.PMMemo = vspoInfo.PMMemo.Trim(); } localEntiy.EstimateArriveTime = vspoInfo.EstimateArriveTime; localEntiy.InStockOrderSysNo = vspoInfo.InStockOrderSysNo; localEntiy.InStockOrderType = vspoInfo.InStockOrderType; VSPurchaseOrderDA.UpdateVSPO(localEntiy); //在保存,作废,CSMemo的时候 邮件发送 SendEmailWhenUpdate(PurchaseOrderOperationType.Update, localEntiy); //写LOG: CommonService.WriteLog<VSPOEntity>(entity, " Updated VSPO ", entity.SysNo.Value.ToString(), (int)LogType.St_SOVirtualItemRequest_Save); ExternalDomainBroker.CreateLog(" Updated VSPO " , BizEntity.Common.BizLogType.St_SOVirtualItemRequest_Save , vspoInfo.SysNo.Value , vspoInfo.CompanyCode); scope.Complete(); } return(vspoInfo); }
/// <summary> /// 批量创建PO单: /// </summary> /// <param name="list"></param> public virtual BatchCreateBasketResultInfo BatchCreatePurchaseOrder(List <BasketItemsInfo> list) { List <ProductPMLine> tPMLineList = ExternalDomainBroker.GetProductLineInfoByPM(ServiceContext.Current.UserSysNo); bool tIsManager = list[0].IsManagerPM.Value; //如果没有产品线权限并且不是高级PM,则不允许创建 //if ((tPMLineList == null || tPMLineList.Count == 0) && !tIsManager) //{ // throw new BizException(GetMessageString("Basket_PMNoLine")); //} FillProductLineInfo(list); string createCompanyCode = string.Empty; var conditionList = new List <BasketItemsInfo>(); List <int> POSysNo = new List <int>(); string errorMsg = ""; //根据编号加载商品信息: string exceptionMsg = CheckBasketInfo(ref list); errorMsg += exceptionMsg; List <PurchaseOrderInfo> POs = new List <PurchaseOrderInfo>(); //if (!string.IsNullOrEmpty(exceptionMsg) || exceptionMsg.Length > 0) //{ // throw new BizException(exceptionMsg); //} list.ForEach(x => { //是否中转: if (x.IsTransfer == 1) { x.StockSysNo = 5000 + x.StockSysNo; } createCompanyCode = x.CompanyCode; }); //默认采购单类型为:正常;增值税率:0.17;结算货币:人民币(1);送货类型:厂房直送(12) var group = from item in list group item by new { item.IsConsign, item.StockSysNo, item.VendorSysNo, item.PMSysNo, item.IsTransfer, item.ProductLine_SysNo } into g select new { Key = g.Key, ResultList = g }; foreach (var item in group) { POs.Clear(); var ZPO = from i in item.ResultList where i.Quantity >= 0 select i; var FPO = from i in item.ResultList where i.Quantity < 0 select i; //正采购 #region ZPO if (ZPO.Count() > 0) { PurchaseOrderInfo modelPO = GetInitPO(createCompanyCode); modelPO.VendorInfo = VendorProcessor.LoadVendorInfo(item.Key.VendorSysNo.Value); modelPO.PurchaseOrderBasicInfo.ConsignFlag = (PurchaseOrderConsignFlag)Enum.Parse(typeof(PurchaseOrderConsignFlag), item.Key.IsConsign.Value.ToString()); if (null == modelPO.PurchaseOrderBasicInfo.StockInfo) { modelPO.PurchaseOrderBasicInfo.StockInfo = new BizEntity.Inventory.StockInfo(); } modelPO.PurchaseOrderBasicInfo.StockInfo.SysNo = item.Key.StockSysNo; if (null == modelPO.PurchaseOrderBasicInfo.ProductManager) { modelPO.PurchaseOrderBasicInfo.ProductManager = new BizEntity.IM.ProductManagerInfo(); } //注释原因:因加入产品线验证,此处的归属PM应为产品线的PM //modelPO.PurchaseOrderBasicInfo.ProductManager.SysNo = item.Key.PMSysNo; modelPO.PurchaseOrderBasicInfo.PurchaseOrderType = PurchaseOrderType.Normal; modelPO.PurchaseOrderBasicInfo.PayType.SysNo = VendorDA.LoadVendorPayPeriodType(item.Key.VendorSysNo); string companyCode = string.Empty; foreach (var POitem in ZPO) { modelPO.PurchaseOrderBasicInfo.PurchaseOrderType = PurchaseOrderType.Normal; //增加产品线和主PM字段回写 modelPO.PurchaseOrderBasicInfo.IsManagerPM = POitem.IsManagerPM; modelPO.PurchaseOrderBasicInfo.ProductManager.SysNo = POitem.PMSysNo; modelPO.PurchaseOrderBasicInfo.ProductLineSysNo = POitem.ProductLine_SysNo; modelPO.POItems.Add(new PurchaseOrderItemInfo() { ItemSysNo = POitem.ItemSysNo, ProductSysNo = POitem.ProductSysNo, Quantity = 0, ReadyQuantity = POitem.ReadyQuantity, OrderPrice = POitem.OrderPrice, ProductID = POitem.ProductID, PurchaseQty = POitem.Quantity, UnitCost = Decimal.Round(POitem.OrderPrice.Value * modelPO.PurchaseOrderBasicInfo.ExchangeRate.Value, 2), Weight = POitem.Weight, ApportionAddOn = 0, ReturnCost = 0, BriefName = POitem.BriefName, AvailableQty = BasketDA.AvailableQtyByProductSysNO(POitem.ProductSysNo.Value), M1 = BasketDA.M1ByProductSysNO(POitem.ProductSysNo.Value), JingDongPrice = BasketDA.JDPriceByProductSysNO(POitem.ProductSysNo.Value), CompanyCode = POitem.CompanyCode }); companyCode = POitem.CompanyCode; } modelPO.CompanyCode = companyCode; POs.Add(modelPO); } #endregion //负采购 #region FPO if (FPO.Count() > 0) { PurchaseOrderInfo modelPO = GetInitPO(createCompanyCode); modelPO.VendorInfo = VendorProcessor.LoadVendorInfo(item.Key.VendorSysNo.Value); modelPO.PurchaseOrderBasicInfo.ConsignFlag = (PurchaseOrderConsignFlag)Enum.Parse(typeof(PurchaseOrderConsignFlag), item.Key.IsConsign.Value.ToString()); modelPO.PurchaseOrderBasicInfo.StockInfo.SysNo = item.Key.StockSysNo; modelPO.PurchaseOrderBasicInfo.ProductManager.SysNo = item.Key.PMSysNo; modelPO.PurchaseOrderBasicInfo.PurchaseOrderType = PurchaseOrderType.Negative; modelPO.PurchaseOrderBasicInfo.PayType.SysNo = VendorDA.LoadVendorPayPeriodType(item.Key.VendorSysNo); modelPO.PurchaseOrderBasicInfo.MemoInfo.Memo = GetMessageString("Basket_Memo_FPO"); string companyCode = string.Empty; foreach (var POitem in FPO) { //增加产品线和主PM字段回写 modelPO.PurchaseOrderBasicInfo.IsManagerPM = POitem.IsManagerPM; modelPO.PurchaseOrderBasicInfo.ProductManager.SysNo = POitem.ProductLine_PMSysNo; modelPO.PurchaseOrderBasicInfo.ProductLineSysNo = POitem.ProductLine_SysNo; modelPO.POItems.Add(new PurchaseOrderItemInfo() { ItemSysNo = POitem.ItemSysNo, ProductSysNo = POitem.ProductSysNo, Quantity = 0, OrderPrice = POitem.OrderPrice, ProductID = POitem.ProductID, PurchaseQty = POitem.Quantity, UnitCost = Decimal.Round(POitem.OrderPrice.Value * modelPO.PurchaseOrderBasicInfo.ExchangeRate.Value, 2), Weight = POitem.Weight, ApportionAddOn = 0, ReturnCost = 0, BriefName = POitem.BriefName, AvailableQty = BasketDA.AvailableQtyByProductSysNO(POitem.ProductSysNo.Value), M1 = BasketDA.M1ByProductSysNO(POitem.ProductSysNo.Value), JingDongPrice = BasketDA.JDPriceByProductSysNO(POitem.ProductSysNo.Value), CompanyCode = POitem.CompanyCode }); companyCode = POitem.CompanyCode; } modelPO.CompanyCode = companyCode; POs.Add(modelPO); } #endregion int poItemCountNumber = 80; if (!string.IsNullOrEmpty(AppSettingManager.GetSetting("PO", "PoItemCountNumber"))) { poItemCountNumber = int.Parse(AppSettingManager.GetSetting("PO", "PoItemCountNumber")); } foreach (var poentity in POs) { try { if (poentity.PurchaseOrderBasicInfo.MemoInfo == null) { poentity.PurchaseOrderBasicInfo.MemoInfo = new PurchaseOrderMemoInfo(); } if (poentity.PurchaseOrderBasicInfo.ETATimeInfo == null) { poentity.PurchaseOrderBasicInfo.ETATimeInfo = new PurchaseOrderETATimeInfo(); } if (poentity.EIMSInfo == null) { poentity.EIMSInfo = new PurchaseOrderEIMSInfo() { EIMSInfoList = new List <EIMSInfo>() }; } if (poentity.ReceivedInfoList == null) { poentity.ReceivedInfoList = new List <PurchaseOrderReceivedInfo>(); } //如果在一个po单中Item超过80种,则自动拆分 每80种商品一单 if (poentity.POItems.Count > poItemCountNumber) { //string listvalue = SerializeHelper.JsonSerializer(poentity); PurchaseOrderInfo posResult = poentity; //SerializeHelper.JsonDeserialize<IPP.Oversea.CN.POASNMgmt.WebModel.ViewModels.PO.POModel>(listvalue); var poitems = new List <PurchaseOrderItemInfo>(); for (int i = 1; i <= poentity.POItems.Count; i++) { poitems.Add(poentity.POItems[i - 1]); if ((i % poItemCountNumber == 0 && i != 0) || i == poentity.POItems.Count) { posResult.POItems = poitems; var poResult = PurchaseOrderProcessor.CreatePO(posResult); POSysNo.Add(poResult.SysNo.Value); poitems.Clear(); } } } else { var poResult = PurchaseOrderProcessor.CreatePO(poentity); POSysNo.Add(poResult.SysNo.Value); } } catch (Exception ex) { errorMsg += ex.Message + Environment.NewLine; } } } return(new BatchCreateBasketResultInfo() { SucessPOSysNos = POSysNo, ErrorMsg = errorMsg }); }
/// <summary> /// 虚库采购单 - 作废 /// </summary> /// <param name="vspoInfo"></param> /// <returns></returns> public virtual VirtualStockPurchaseOrderInfo AdandonVSPO(VirtualStockPurchaseOrderInfo vspoInfo) { #region [Check实体逻辑] //虚库采购单的编号不能为空: if (!vspoInfo.SysNo.HasValue) { //虚库采购单的编号不能为空 throw new BizException(GetMessageString("VSPO_VSPOSysNoEmpty")); } #endregion //虚库采购单为作废状态,不能再作废 VirtualStockPurchaseOrderInfo localEntiy = VSPurchaseOrderDA.LoadVSPO(vspoInfo.SysNo.Value); if (localEntiy == null) { ///该虚库采购单在数据中不存在,操作失败! throw new BizException(GetMessageString("VSPO_VSPONotFound")); } if (localEntiy.Status.HasValue && localEntiy.Status.Value == VirtualPurchaseOrderStatus.Abandon) { //虚库采购单为作废状态,不能再作废! throw new BizException(GetMessageString("VSPO_Abandon_Invalid_Abandon")); } if (vspoInfo.InStockOrderType.Value != VirtualPurchaseInStockOrderType.PO) { vspoInfo.InStockOrderSysNo = Convert.ToInt32(vspoInfo.InStockOrderSysNo.Value.ToString().Substring(2)); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { string strInfo = string.Empty; if (vspoInfo.InStockOrderType == VirtualPurchaseInStockOrderType.Shift) { int isCanAbadon = 0; int shiftsysno = 0; //调用Inventory接口,判断对应的自动移仓单是否已出库 bool isShift = ExternalDomainBroker.IsAutoShift(vspoInfo.InStockOrderSysNo.Value, out isCanAbadon, out shiftsysno); if (isShift) { if (isCanAbadon == 1) { //调用Invoice接口,设置 St_Shift 作废 ExternalDomainBroker.AbandonShift(shiftsysno); } if (isCanAbadon == 0) { //请注意:对应的自动移仓单已出库! strInfo = GetMessageString("VSPO_OutStock_Note"); } } } if (vspoInfo.InStockOrderType.Value != VirtualPurchaseInStockOrderType.PO) { vspoInfo.InStockOrderSysNo = Convert.ToInt32(vspoInfo.InStockOrderSysNo.Value.ToString().Substring(2)); } //更新状态操作: vspoInfo.Status = VirtualPurchaseOrderStatus.Abandon; VSPurchaseOrderDA.AbandonVSPO(vspoInfo); //邮件收发 ////成功作废虚库商品采购单,并发邮件通知PM负责人员 //vspoInfo.Messges = strInfo + MessageResource.VSPO_Check_ConfirmPMRequiredValue; //如果销售单没有生成虚库采购单: int getExistSOCount = VSPurchaseOrderDA.CheckExistsSOVirtualItemRequest(vspoInfo.SOSysNo.Value); if (getExistSOCount == 0) { //调用Order接口,作废虚库采购单后将对应的订单标识为未备货状态: ExternalDomainBroker.UpdateSOCheckShipping(vspoInfo.SOSysNo.Value, VirtualPurchaseOrderStatus.Abandon); } //发送邮件: SendEmailWhenUpdate(PurchaseOrderOperationType.Abandon, vspoInfo); //写LOG:CommonService.WriteLog<VSPOEntity>(entity, " Abandon VSPO ", entity.SysNo.Value.ToString(), (int)LogType.St_SOVirtualItemRequest_Abandon); ExternalDomainBroker.CreateLog(" Abandon VSPO " , BizEntity.Common.BizLogType.St_SOVirtualItemRequest_Abandon , vspoInfo.SysNo.Value , vspoInfo.CompanyCode); scope.Complete(); } return(vspoInfo); }