/// <summary> /// 关闭佣金结算单 /// </summary> /// <param name="commission"></param> /// <param name="callback"></param> public void CloseCommission(CommissionMaster commission, EventHandler <RestClientEventArgs <CommissionMaster> > callback) { commission.CompanyCode = CPApplication.Current.CompanyCode; string relativeUrl = "/POService/Commission/CloseVendorCommission"; restClient.Update(relativeUrl, commission, callback); }
/// <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); }
private void btnClose_Click(object sender, RoutedEventArgs e) { //关闭结算单: Window.Confirm(ResCommissionItemView.ConfirmMsg_Close, (obj, args) => { if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK) { CommissionMaster request = EntityConverter <CommissionMasterVM, CommissionMaster> .Convert(masterVM); serviceFacade.CloseCommission(request, (obj2, args2) => { if (args2.FaultsHandle()) { return; } Window.Alert(ResCommissionItemView.InfoMsg_AlertTitle, ResCommissionItemView.InfoMsg_CloseSuccess, MessageType.Information, (obj3, args3) => { if (args3.DialogResult == DialogResultType.Cancel) { Window.Navigate("/ECCentral.Portal.UI.PO/CommissionQuery", false); } }); }); } }); }
public void SendMailForProductWithNoVendorManufacturer(IEnumerable <CommissionLog> items) { var vendors = from item in items group item by item.MerchantSysNo into g select g; foreach (var itemsForVendor in vendors) { if (merchants.Select(x => x.SysNo).Contains(itemsForVendor.Key)) { StringBuilder sbMessage = new StringBuilder(); CommissionMaster master = new CommissionMaster { MerchantSysNo = itemsForVendor.Key }; SetCommissionTimeInfo(master, DateTime.Now); sbMessage.AppendLine(string.Format("供应商系统编号:{0} 账期{1:yyyy-MM-dd} --> {2:yyyy-MM-dd}", master.MerchantSysNo, master.BeginDate, master.EndDate)); foreach (var product in itemsForVendor) { sbMessage.AppendLine(string.Format("订单类型:{0} 订单编号:{1} 商品系统编号:{2}", product.ReferenceType, product.ReferenceSysNo, product.ProductSysNo)); } dal.SendEmail(GlobalSettings.AlertMailAddress, GlobalSettings.AlertMailSubject, sbMessage.ToString(), 0); } } }
/// <summary> /// 批量关闭佣金信息 /// </summary> /// <param name="commissionMaster"></param> /// <returns></returns> public virtual int BatchCloseCommissions(List <CommissionMaster> commissionList) { int result = 0; //预先检查状态是否满足关闭条件: string ErrorMsg = BatchCheckCommissionStatus(commissionList); if (!string.IsNullOrEmpty(ErrorMsg)) { throw new BizException(ErrorMsg); } //进行批量关闭操作: foreach (var commission in commissionList) { string getSysNo = commission.SysNo.Value.ToString(); if (!string.IsNullOrEmpty(getSysNo)) { int tempSysNo = int.Parse(getSysNo); CommissionMaster entity = new CommissionMaster() { SysNo = tempSysNo }; if (null != CloseCommission(entity)) { result++; } ; } } return(result); }
/// <summary> /// 检查状态是否满足关闭条件 /// </summary> /// <param name="commissionSysNos"></param> /// <returns></returns> public virtual string BatchCheckCommissionStatus(List <CommissionMaster> commissionList) { string errorMsg = string.Empty; foreach (var commission in commissionList) { string commissionSysNo = commission.SysNo.Value.ToString(); if (!string.IsNullOrEmpty(commissionSysNo)) { int tempSysNo = int.Parse(commissionSysNo); CommissionMaster commissionMaster = CommissionDA.LoadCommissionMaster(tempSysNo); if (!commissionMaster.SysNo.HasValue) { //佣金账扣单编号不能为空! errorMsg += string.Format(GetMessageString("Commission_SysNoEmpty"), tempSysNo); } if (commissionMaster.Status != VendorCommissionMasterStatus.SET) { //编号为{0}的佣金账扣单不为'已出单'状态,不能关闭! errorMsg += string.Format(GetMessageString("Commission_SetStatusInvalid"), tempSysNo); } if (commissionMaster.SettleStatus != VendorCommissionSettleStatus.Abandon) { //编号为{0}的佣金账扣单对应的财务单据不为'已作废'状态,请先作废相应的付款单! errorMsg += string.Format(GetMessageString("Commission_AbandonStatusInvalid"), tempSysNo); } } } return(errorMsg); }
public void InsertCommissionMaster(CommissionMaster req) { DataCommand command = DataCommandManager.GetDataCommand("InsertCommissionMaster"); command.SetParameterValue <CommissionMaster>(req, true, false); command.SetParameterValue("@InUser", ServiceContext.Current.UserSysNo); req.SysNo = command.ExecuteScalar <int>(); }
/// <summary> /// 结算已经到账期的佣金单据 /// </summary> /// <param name="master"></param> private void SettleCommission(CommissionMaster master) { DisplayMessage(string.Format("佣金结算单{0}调用财务接口", master.SysNo)); master.Status = Constants.CommissionMasterStatus.Settled; master.EndDate = DateTime.Now; dal.UpdateCommissionMaster(master); CreatePayItem(master); dal.SettleCommission(master); }
public Int32 SettleCommission(CommissionMaster item) { DataCommand command = DataCommandManager.GetDataCommand("CloseCommissionMaster"); command.SetParameterValue("@SysNo", item.SysNo); command.SetParameterValue("@Status", item.Status); command.SetParameterValue("@CompanyCode", GlobalSettings.CompanyCode); return(command.ExecuteNonQuery()); }
bool IsOnlyCalculateRentFee(CommissionMaster master) { bool result = false; if (!string.IsNullOrEmpty(GlobalSettings.OnlyCalcRentFeeAccType)) { Vendor vendor = dal.GetVendorBySysNo(master.MerchantSysNo); result = GlobalSettings.OnlyCalcRentFeeAccType.Split(',').Select(p => int.Parse(p)).Contains(vendor.PayPeriodType); } return(result); }
/// <summary> /// 计算总店租佣金 /// </summary> /// <param name="master"></param> private void SetTotalRent(CommissionMaster master) { var rulesForVendor = dal.GetCommissionRulesByMerchantSysNo(master.MerchantSysNo); master.RentFee = rulesForVendor.Sum(x => x.RentFee) * master.Percentage; foreach (var rule in rulesForVendor) { var item = dal.GetCommissionItemByVMSysNo(rule.VendorManufacturerSysNo, master.SysNo); item.RuleSysNo = rule.SysNo; item.Rent = rule.RentFee * master.Percentage; dal.UpdateCommissionItem(item); } }
public void InsertCommissionItems(CommissionMaster req) { foreach (var item in req.ItemList) { if (item.RuleSysNo == 0) { item.DeliveryFee = item.TotalSaleAmt = item.OrderCommissionFee = item.SalesCommissionFee = item.RentFee = 0; } DataCommand command = DataCommandManager.GetDataCommand("InsertCommissionItem"); command.SetParameterValue <CommissionItem>(item, true, false); command.SetParameterValue("@InUser", ServiceContext.Current.UserSysNo); command.SetParameterValue("@CompanyCode", req.CompanyCode); command.SetParameterValue("@CommissionMasterSysNo", req.SysNo); item.ItemSysNo = command.ExecuteScalar <int>(); } }
public Int32 UpdateCommissionMaster(CommissionMaster item) { DataCommand command = DataCommandManager.GetDataCommand("UpdateCommissionMaster"); command.SetParameterValue("@SysNo", item.SysNo); command.SetParameterValue("@MerchantSysNo", item.MerchantSysNo); command.SetParameterValue("@Status", item.Status); command.SetParameterValue("@TotalAmt", item.TotalAmt); command.SetParameterValue("@RentFee", item.RentFee); command.SetParameterValue("@DeliveryFee", item.DeliveryFee); command.SetParameterValue("@SalesCommissionFee", item.SalesCommissionFee); command.SetParameterValue("@OrderCommissionFee", item.OrderCommissionFee); command.SetParameterValue("@BeginDate", item.BeginDate); command.SetParameterValue("@EndDate", item.EndDate); command.SetParameterValue("@CompanyCode", GlobalSettings.CompanyCode); return(command.ExecuteNonQuery()); }
public ActionResult DeletePartial(CommissionMaster comm) { comm.Status = "InActive"; comm.ModifiedOn = DateTime.Now; _CommissionService.Update(comm); var productlist = _CommissionProductService.GetDetailsByCommCode(comm.CommissionCode); if (productlist != null) { foreach (var data in productlist) { data.Status = "InActive"; data.ModifiedOn = DateTime.Now; _CommissionProductService.Update(data); } } return(RedirectToAction("Details/" + Convert.ToInt32(comm.CommissionId), "Commission")); }
protected override PayItemInfo PreCheckForCancelAbandon(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = base.PreCheckForCancelAbandon(entity, out payableInfo); CommissionMaster commissionMaster = ExternalDomainBroker.GetCommissionMaster(payableInfo.OrderSysNo.Value); if (commissionMaster.Status == VendorCommissionMasterStatus.SET) { if (payItemInfo.PayStyle != PayItemStyle.Normal) { ThrowBizException("PayItem_CancelAbandon_VendorSettleOrderStatusNotMatchPayStyleForCommissionMaster"); } } else { ThrowBizException("PayItem_CancelAbandon_VendorSettleOrderStatusNotSettledForCommissionMaster"); } return(payItemInfo); }
protected override void PreCheckForCreate(PayItemInfo entity) { base.PreCheckForCreate(entity); CommissionMaster commissionMaster = ExternalDomainBroker.GetCommissionMaster(entity.OrderSysNo.Value); if (commissionMaster == null) { ThrowBizException("PayItem_OrderNotExisitsFormat", entity.OrderSysNo); } //填写佣金账扣上的CompanyCode为付款单CompanyCode entity.CompanyCode = commissionMaster.CompanyCode; entity.OrderStatus = (int?)commissionMaster.Status; if (commissionMaster.Status == VendorCommissionMasterStatus.SET) { if (entity.PayStyle != PayItemStyle.Normal) { ThrowBizException("PayItem_Create_OnlyCanAddNormalPayForVendorSettleOrder"); } } else { ThrowBizException("PayItem_Create_CommissionMasterStatusInvalid"); } List <PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo() { OrderSysNo = entity.OrderSysNo, OrderType = entity.OrderType }); //如果该单据已经有支付,对该应付作检查 if (payList != null && payList.Count > 0) { ReferencePayableInfo = payList[0]; if (ReferencePayableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_Create_FullPay"); } } }
/// <summary> /// /// </summary> /// <param name="commissionSysNo"></param> /// <returns></returns> public virtual CommissionMaster LoadCommissionInfo(int commissionSysNo) { CommissionMaster returnEntity = new CommissionMaster(); //1.加载佣金主信息: returnEntity = CommissionDA.LoadCommissionMaster(commissionSysNo); if (returnEntity == null) { throw new BizException(GetMessageString("Commission_Error_InvalidItem")); } //2.加载Item信息: returnEntity.ItemList = CommissionDA.LoadCommissionItems(commissionSysNo); //3.加载佣金详细信息: if (null != returnEntity.ItemList) { returnEntity.ItemList.ForEach(x => { switch (x.CommissionType) { case VendorCommissionItemType.DEF: x.DetailDeliveryList = CommissionDA.LoadCommissionItemDetails(x.ItemSysNo.Value, x.CommissionType); break; case VendorCommissionItemType.SOC: x.DetailOrderList = CommissionDA.LoadCommissionItemDetails(x.ItemSysNo.Value, x.CommissionType); break; case VendorCommissionItemType.SAC: x.DetailList = CommissionDA.LoadCommissionItemDetails(x.ItemSysNo.Value, x.CommissionType); break; } x.TotalQty = x.TotalQty ?? 0; }); } return(returnEntity); }
public CommissionMaster GetManualCommissionMaster(CommissionMaster req) { return(ObjectFactory <CommissionAppService> .Instance.GetManualCommissionMaster(req)); }
public CommissionMaster CloseCommission(CommissionMaster commissionMaster) { return(ObjectFactory <CommissionAppService> .Instance.CloseCommission(commissionMaster)); }
private void SetCommissionTimeInfo(CommissionMaster master, DateTime now) { Vendor vendor = dal.GetVendorBySysNo(master.MerchantSysNo); DateTime startTime, endTime; if (!payPeriods.ContainsKey(vendor.PayPeriodType)) { throw new Exception(string.Format("供应商{0} 账期{1} 没有找到对应的账期配置信息", vendor.SysNo, vendor.PayPeriodType)); } var rule = payPeriods[vendor.PayPeriodType]; var daysOfMonth = rule.Split(',').Select(x => Convert.ToInt32(x)).ToList(); if (daysOfMonth.Count > 2 || daysOfMonth.Count == 0) { throw new NotSupportedException("账期配置错误,当前版本仅支持半月结与整月结"); } else if (daysOfMonth.Count == 1) { if (daysOfMonth[0] < 0 || daysOfMonth[0] > 31) { throw new OverflowException(string.Format("{0}不是合法的日期,应该为1 ~ 30之间的整数", daysOfMonth[0])); } if (now.Day <= daysOfMonth[0]) { startTime = new DateTime(now.Year, now.Month, daysOfMonth[0]).AddMonths(-1); } else { startTime = new DateTime(now.Year, now.Month, daysOfMonth[0]); } endTime = startTime.AddMonths(1); master.Percentage = 1m; } else { var min = daysOfMonth.Min(); var max = daysOfMonth.Max(); if (min < 0 || max > 30) { throw new OverflowException(string.Format("Start:{0} End:{1}不是合法的日期,应该为1 ~ 30之间的整数", min, max)); } if (now.Day <= min) { startTime = new DateTime(now.Year, now.Month, max).AddMonths(-1); endTime = new DateTime(now.Year, now.Month, min); } else if (now.Day <= max) { startTime = new DateTime(now.Year, now.Month, min); endTime = new DateTime(now.Year, now.Month, max); } else { startTime = new DateTime(now.Year, now.Month, max); endTime = new DateTime(now.Year, now.Month, min).AddMonths(1); } master.Percentage = 0.5m; } master.BeginDate = startTime; master.EndDate = endTime; }
public void Update(CommissionMaster comm) { _CommissionRepository.Update(comm); _unitOfWork.Commit(); }
public void Create(CommissionMaster Comm) { _CommissionRepository.Add(Comm); _unitOfWork.Commit(); }
public CommissionMaster CreateSettleCommission(CommissionMaster req) { return(ObjectFactory <CommissionAppService> .Instance.CreateSettleCommission(req)); }
/// <summary> /// 关闭佣金 /// </summary> /// <param name="commissionMaster"></param> /// <returns></returns> public CommissionMaster CloseCommission(CommissionMaster commissionMaster) { return(CommissionProcessor.CloseCommission(commissionMaster)); }
public CommissionMaster GetManualCommissionMaster(CommissionMaster master, bool isCreateCommission = false) { #region valid if (!master.MerchantSysNo.HasValue) { throw new BizException(GetMessageString("Commission_Error_VendorSelect")); } if (!master.BeginDate.HasValue || !master.EndDate.HasValue) { throw new BizException(GetMessageString("Commission_Error_DateSelect")); } if (master.BeginDate.Value > master.EndDate.Value) { throw new BizException(GetMessageString("Commission_Error_StartMoreThanEnd")); } DateTime now = DateTime.Now; if (master.EndDate.Value > now.Date.AddDays(1)) { throw new BizException(GetMessageString("Commission_Error_EndMoreThanNow")); } if (master.EndDate.Value > now) { master.EndDate = now; } if (isCreateCommission) { //供应商是否可手工结算 var vendorInfo = ObjectFactory <VendorProcessor> .Instance.LoadVendorFinanceInfo(master.MerchantSysNo.Value); if (vendorInfo == null) { throw new BizException(GetMessageString("Commission_Error_InvalidPayPeriod")); } var manualPayPeriodTypes = AppSettingManager.GetSetting("PO", "ManualSettleCommissionPayType").Split(','); if (!manualPayPeriodTypes.ToList().Exists(p => p == (vendorInfo.PayPeriodType.PayTermsNo ?? 0).ToString())) { throw new BizException(GetMessageString("Commission_Error_NotManualPayPeriod")); } } #endregion #region load data master.ItemList = new List <CommissionItem>(); var details = CommissionDA.QueryCommissionItemDetails(master.MerchantSysNo.Value, master.BeginDate.Value, master.EndDate.Value, master.CompanyCode); if (details != null) { var groupDetails = details.Where(p => p.VendorManufacturerSysNo > 0).GroupBy(p => p.VendorManufacturerSysNo); var rules = CommissionDA.QueryCommissionRuleByMerchantSysNo(master.MerchantSysNo.Value); if (rules.Count > 0) { foreach (var group in groupDetails) { var commissionItem = new CommissionItem(); commissionItem.VendorManufacturerSysNo = group.Key; var rule = rules.FirstOrDefault(p => p.VendorManufacturerSysNo == group.Key); if (rule == null || string.IsNullOrEmpty(rule.StagedSaleRuleItemsXml)) { commissionItem.RuleSysNo = 0; } else { rule.SaleRuleEntity = SerializationUtility.XmlDeserialize <VendorStagedSaleRuleEntity>(rule.StagedSaleRuleItemsXml); var agent = group.Where(p => !string.IsNullOrEmpty(p.ReferenceSysNo)); if (agent == null) { continue; } agent.ForEach(p => p.SalePrice = Math.Round((p.SalePrice ?? 0) - (p.Point ?? 0) / 10m - Math.Abs((p.DiscountAmout ?? 0) / (p.Quantity ?? 0)), 2)); commissionItem.TotalSaleAmt = agent.Sum(p => p.SalePrice * (p.Quantity ?? 0) - Math.Abs(p.PromotionDiscount)); commissionItem.RentFee = rule.RentFee; //销售提成不在比较保底 //commissionItem.SalesCommissionFee = Math.Max(GetSaleCommissionAmount(commissionItem.TotalSaleAmt, rule.RuleEntity), rule.RuleEntity.MinCommissionAmt); commissionItem.SalesCommissionFee = GetSaleCommissionAmount(commissionItem.TotalSaleAmt ?? 0, rule.SaleRuleEntity); commissionItem.DetailList = agent.ToList(); #region 初算提成和运费 #region 运费 commissionItem.DetailDeliveryList = new List <CommissionItemDetail>(); foreach (var item in agent) { if (item.ReferenceType == VendorCommissionReferenceType.SO && !commissionItem.DetailDeliveryList.Exists(p => p.ReferenceSysNo == item.ReferenceSysNo)) { commissionItem.DetailDeliveryList.Add(item); } } commissionItem.DeliveryFee = rule.DeliveryFee; #endregion #region 订单提成 commissionItem.DetailOrderList = new List <CommissionItemDetail>(); foreach (var item in agent) { if (item.ReferenceType == VendorCommissionReferenceType.SO && !commissionItem.DetailOrderList.Exists(p => p.ReferenceSysNo == item.ReferenceSysNo)) { commissionItem.DetailOrderList.Add(item); } } var autoRmaOrder = new List <CommissionItemDetail>(); foreach (var autoRma in agent.Where(p => p.ReferenceType == VendorCommissionReferenceType.RMA && p.HaveAutoRMA)) { if (!autoRmaOrder.Exists(p => p.SOSysNo == autoRma.SOSysNo)) { autoRmaOrder.Add(autoRma); } } commissionItem.OrderCommissionFee = rule.OrderCommissionAmt; commissionItem.DetailOrderList.AddRange(autoRmaOrder); #endregion #endregion commissionItem.RuleSysNo = rule.CommissionSysNo; commissionItem.SaleRule = rule.SaleRuleEntity; #region 更新基础信息 SetDetailDetailSysNo(commissionItem.DetailList); SetDetailDetailSysNo(commissionItem.DetailOrderList); SetDetailDetailSysNo(commissionItem.DetailDeliveryList); var itemBaseInfo = CommissionDA.QueryVendorManufacturerBySysNo(group.Key); if (itemBaseInfo != null) { commissionItem.ManufacturerName = itemBaseInfo.ManufacturerName; commissionItem.BrandName = itemBaseInfo.BrandName; commissionItem.C3Name = itemBaseInfo.C3Name; commissionItem.C2Name = itemBaseInfo.C2Name; } #endregion } master.ItemList.Add(commissionItem); } #region 细算 //如果一个订单有两个或者多个供应商,需获取最大的进行匹配计算,此逻辑为订单提成和运费相关 var itemList = master.ItemList; for (int i = 0; i < itemList.Count; i++) { if (itemList[i].RuleSysNo == 0) { continue; } #region 运费 if (itemList[i].DetailDeliveryList != null) { for (int k = 0; k < itemList[i].DetailDeliveryList.Count;) { var detail = itemList[i].DetailDeliveryList[k]; k++; for (int j = i + 1; j < itemList.Count; j++) { if (itemList[j].DetailDeliveryList != null && itemList[j].DetailDeliveryList.Exists(p => p.ReferenceSysNo == detail.ReferenceSysNo && itemList[i].DeliveryFee.Value <= itemList[j].DeliveryFee.Value)) { itemList[i].DetailDeliveryList.Remove(detail); k--; break; } } } } #endregion #region 订单提成 if (itemList[i].DetailOrderList != null) { for (int k = 0; k < itemList[i].DetailOrderList.Count;) { var detail = itemList[i].DetailOrderList[k]; k++; for (int j = i + 1; j < itemList.Count; j++) { if (itemList[j].DetailOrderList != null && itemList[j].DetailOrderList.Exists(p => p.ReferenceSysNo == detail.ReferenceSysNo && itemList[i].OrderCommissionFee <= itemList[j].OrderCommissionFee)) { //移除较低价的订单 itemList[i].DetailOrderList.Remove(detail); k--; break; } } } } #endregion itemList[i].DeliveryQty = itemList[i].DetailDeliveryList.Count; itemList[i].TotalDeliveryFee = itemList[i].DeliveryQty * itemList[i].DeliveryFee; itemList[i].OrderQty = itemList[i].DetailOrderList.Count; itemList[i].TotalOrderCommissionFee = (itemList[i].DetailOrderList.Count(p => p.ReferenceType == VendorCommissionReferenceType.SO) - itemList[i].DetailOrderList.Count(p => p.ReferenceType == VendorCommissionReferenceType.RMA)) * itemList[i].OrderCommissionFee; } #endregion //手工结算店租为0 //master.RentFee = rules.Sum(p => p.RentFee ?? 0); master.RentFee = 0; master.DeliveryFee = master.ItemList.Sum(p => p.TotalDeliveryFee ?? 0); master.OrderCommissionFee = master.ItemList.Sum(p => p.TotalOrderCommissionFee ?? 0); master.SalesCommissionFee = master.ItemList.Sum(p => p.SalesCommissionFee ?? 0); master.TotalAmt = master.RentFee + master.DeliveryFee + master.OrderCommissionFee + master.SalesCommissionFee; } } #endregion return(master); }
public CommissionMaster CreateSettleCommission(CommissionMaster req) { return(CommissionProcessor.CreateSettleCommission(req)); }
public CommissionMaster GetManualCommissionMaster(CommissionMaster req) { return(CommissionProcessor.GetManualCommissionMaster(req)); }
public void CreatePayItem(CommissionMaster master) { //获取配置参数 string baseUrl = System.Configuration.ConfigurationManager.AppSettings["InvoiceRestFulBaseUrl"]; string languageCode = System.Configuration.ConfigurationManager.AppSettings["LanguageCode"]; string companyCode = System.Configuration.ConfigurationManager.AppSettings["CompanyCode"]; int? UserSysNo = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["UserSysNo"]); #region 转化数据 PayItemInfo payItem = new PayItemInfo(); payItem = new PayItemInfo() { OrderSysNo = master.SysNo, Note = "自动结算佣金", PayAmt = -Math.Round(master.TotalAmt, 2), OrderType = PayableOrderType.Commission, EditUserSysNo = UserSysNo, PayStyle = PayItemStyle.Normal, BatchNumber = 1, CompanyCode = GlobalSettings.CompanyCode }; #endregion ECCentral.Job.Utility.RestClient client = new ECCentral.Job.Utility.RestClient(baseUrl, languageCode); ECCentral.Job.Utility.RestServiceError error; var ar = client.Create("/PayItem/Create", payItem, out error); if (error != null && error.Faults != null && error.Faults.Count > 0) { string errorMsg = string.Empty; foreach (var errorItem in error.Faults) { errorMsg += errorItem.ErrorDescription; } Logger.WriteLog(errorMsg, "JobConsole"); } #region FINISH 服务调用 //?? //ICreatePayItemV31 service = null; //try //{ // service = ServiceBroker.FindService<ICreatePayItemV31>(); // if (service == null) // { // throw new InvalidOperationException("未找到ICreatePayItemV31服务"); // } // PayItemV31 payItem = new PayItemV31(); // payItem.Header = new Newegg.Oversea.Framework.Contract.MessageHeader // { // CompanyCode = GlobalSettings.CompanyCode, // OperationUser = new Newegg.Oversea.Framework.Contract.OperationUser // { // CompanyCode = GlobalSettings.CompanyCode, // FullName = GlobalSettings.UserName, // LogUserName = GlobalSettings.UserName, // SourceDirectoryKey = GlobalSettings.SourceDirectoryKey, // SourceUserName = GlobalSettings.UserName, // UniqueUserName = GlobalSettings.UserName // }, // StoreCompanyCode = GlobalSettings.StoreCompanyCode, // FromSystem = GlobalSettings.FromIP // }; // payItem.Body = new PayItemMessage // { // OrderSysNo = master.SysNo, // Note = "自动结算佣金", // PayAmt = -Math.Round(master.TotalAmt,2), // OrderType = PayableOrderType.Commission, // OperUserName = GlobalSettings.UserName, // PayStyle = PayItemStyle.Normal, // BatchNumber = 1 // }; // var result = service.Create(payItem); // if (result.Faults != null && result.Faults.Count > 0) // { // SendMailForWCFFailure(result); // } //} //catch(Exception ex) //{} //finally //{ // ServiceBroker.DisposeService<ICreatePayItemV31>(service); //} #endregion }
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); }