/// <summary> /// 根据订单系统编号获取订单主项信息 /// </summary>GetSOMasterInfoBySysNo /// <param name="sysNo">订单系统编号</param> /// <returns></returns> public static SOMasterEntity GetSOMasterInfoBySysNo(int sysNo, string companyCode) { DataCommand command = DataCommandManager.GetDataCommand("GetSOMasterInfoBySysNo"); command.SetParameterValue("@SysNo", sysNo); command.SetParameterValue("@CompanyCode", companyCode); SOMasterEntity somaster = command.ExecuteEntity <SOMasterEntity>(); return(somaster); }
private static int DoProcess(DateTime currentDate, int pointType) { List <SOMasterEntity> list = SendAmbassadorPointsDA.GetSO(pointType, currentDate, startNumber); if (list == null || list.Count == 0) { return(0); } Dictionary <string, int> customerPointDictionary = new Dictionary <string, int>(); List <CustomerPointsAddRequest> pointRequestList = new List <CustomerPointsAddRequest>(); foreach (SOMasterEntity so in list) { if (pointRequestList.Exists(delegate(CustomerPointsAddRequest item) { return(item.SOSysNo.Value == so.SysNo); } )) { continue; } #region Get Refund List <RmaRefundEntity> refundList = SendAmbassadorPointsDA.GetRefundBySO(so.SysNo); //退款单为待审核状态Job不加积分 if (refundList.Exists(delegate(RmaRefundEntity item) { return(item.Status == 3); })) { startNumber++; continue; } decimal refundAmount = Convert.ToInt32(refundList.Sum(delegate(RmaRefundEntity item) { if (item.Status == 0 || item.Status == 2) { return(item.PointAmt * 0.1m + item.CashAmt); } return(0); })); #endregion decimal soAmount = so.CashPay + so.DiscountAmt + so.PointPay * 0.1m; //团购订单 if (so.SOType == 7) { SOMasterEntity groupBuyingSo = SendAmbassadorPointsDA.GetGroupBuyingSO(so.SysNo); decimal soGroupBuyingAmount = groupBuyingSo.CashPay + groupBuyingSo.DiscountAmt + groupBuyingSo.PointPay * 0.1m; soAmount = soAmount - soGroupBuyingAmount; } //拆单的情况 if (so.Status == -6) { //所有子单金额 List <SOMasterEntity> allSOList = SendAmbassadorPointsDA.GetAllSubSO(so.SysNo); soAmount = 0.0m; foreach (SOMasterEntity soEntity in allSOList) { soAmount += soEntity.CashPay + soEntity.DiscountAmt + soEntity.PointPay * 0.1m; } //作废子单金额 List <SOMasterEntity> invalidList = SendAmbassadorPointsDA.GetInValidSubSO(so.SysNo); decimal invalidAmount = 0.0m; foreach (SOMasterEntity invalidSO in invalidList) { invalidAmount += invalidSO.CashPay + invalidSO.DiscountAmt + invalidSO.PointPay * 0.1m; } //作废团购订单金额 SOMasterEntity groupbuyingSO = SendAmbassadorPointsDA.GetGroupBuyingSubSO(so.SysNo); decimal groupbuyingAmount = groupbuyingSO.CashPay + groupbuyingSO.DiscountAmt + groupbuyingSO.PointPay * 0.1m; soAmount = soAmount - invalidAmount - groupbuyingAmount; } int pointAmount = (int)(rate * (soAmount - refundAmount) * 10); if (pointAmount <= 0) { startNumber++; continue; } #region add AdjustPointRequest CustomerPointsAddRequest pointRequest = new CustomerPointsAddRequest(); //pointRequest.CompanyCode = AppConfigHelper.CompanyCode; pointRequest.CustomerSysNo = so.AgentSysNo; pointRequest.Memo = so.SysNo.ToString(); pointRequest.NewEggAccount = SysAccount; pointRequest.Note = "新蛋大使订单加积分"; pointRequest.Point = pointAmount; pointRequest.PointType = pointType; pointRequest.SOSysNo = so.SysNo; pointRequest.Source = "IPP.MKT.SendAmbassadorPoints"; pointRequestList.Add(pointRequest); #endregion } BatchAdjustPointService(pointRequestList); return(pointRequestList.Count); }