Ejemplo n.º 1
0
        public void OnPreLoad()
        {
            BooterLogger.AddError(SocialRHSReplacer.Perform<CommonSocials>("Trick Or Treat", "OnTrickOrTreatAccept"));

            InteractionTuning tuning = Tunings.GetTuning<Sprinkler, Sprinkler.PlayWithSprinkler.Definition>();

            if (tuning != null)
            {
                CommodityChange change = new CommodityChange(CommodityKind.Temperature, 10, false, 20, OutputUpdateType.ContinuousFlow, false, false, UpdateAboveAndBelowZeroType.Either);
                tuning.mTradeoff.mOutputs.Add(change);                
            }
        }
Ejemplo n.º 2
0
        public void OnPreLoad()
        {
            BooterLogger.AddError(SocialRHSReplacer.Perform <CommonSocials>("Trick Or Treat", "OnTrickOrTreatAccept"));

            InteractionTuning tuning = Tunings.GetTuning <Sprinkler, Sprinkler.PlayWithSprinkler.Definition>();

            if (tuning != null)
            {
                CommodityChange change = new CommodityChange(CommodityKind.Temperature, 10, false, 20, OutputUpdateType.ContinuousFlow, false, false, UpdateAboveAndBelowZeroType.Either);
                tuning.mTradeoff.mOutputs.Add(change);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.UserNameDTO> GetUserListExt()
        {
            List <Guid> SubId  = (from n in CommodityChange.ObjectSet() where n.SubId != null select n.SubId).Distinct().ToList();
            List <Guid> ModId  = (from n in CommodityChange.ObjectSet() where n.ModifiedId != null select n.ModifiedId).Distinct().ToList();
            List <Guid> userid = SubId.Union(ModId).Distinct().ToList();
            CBCSVFacade CBCSV  = new CBCSVFacade();
            List <Jinher.AMP.BTP.Deploy.CustomDTO.UserNameDTO> userinfolist = CBCSV.GetUserNameByIds(userid).Select(s => new UserNameDTO {
                UserId = s.UserId, UserName = s.UserName
            }).ToList();

            //京东自动改价修改人信息
            userinfolist.Add(new UserNameDTO {
                UserId = new Guid("9AF7F46A-EA52-4AA3-B8C3-9FD484C2AF12"), UserName = "******"
            });
            return(userinfolist);
        }
Ejemplo n.º 4
0
        static JapLowDinnerTable()
        {
            CommodityChange item = new CommodityChange((CommodityKind)286210343, 100f, true, 100f, OutputUpdateType.ImmediateDelta, false, false, UpdateAboveAndBelowZeroType.Either);

            try
            {
                InteractionTuning tuning = AutonomyTuning.GetTuning(typeof(JapLowDinnerTable.Eat.Definition).FullName, typeof(JapLowDinnerTable).FullName);
                tuning.mTradeoff.mOutputs.Add(item);
                tuning = AutonomyTuning.GetTuning(typeof(JapLowDinnerTable.ServeMeal.Definition).FullName, typeof(ServingContainerGroup).FullName);
                tuning.mTradeoff.mOutputs.Add(item);
            }
            catch (Exception ex)
            {
                JapLowDinnerTable.DebugMsg("InteractionTuning(s) not updated\n\n" + ex.StackTrace.Substring(0, JapLowDinnerTable.UMIN(750, ex.StackTrace.Length)));
            }
            JapLowDinnerTable.mSurfaceAddOn = new SurfaceAddOn();
            JapLowDinnerTable.mSurfaceAddOn.AddSurface("ContainmentSlot_0", 1f, SurfaceType.Eating, SurfaceHeight.CoffeeTable, CarrySystemPutDownRule.Default, null);
            World.OnWorldLoadFinishedEventHandler += JapLowDinnerTable.OnWorldLoadFinished;
        }
Ejemplo n.º 5
0
        public override bool Run()
        {
            if (!SafeToSync())
            {
                return(false);
            }

            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                             as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }

            skillTarget = Target.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillTarget == null)
            {
                skillTarget = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                              as EWPetFightingSkill;
                if (skillTarget == null)
                {
                    return(false);
                }
            }

            skillActor.StartSkillGain(skillActor.getSkillGainRate(Actor));
            skillTarget.StartSkillGain(skillTarget.getSkillGainRate(Target));

            BeginCommodityUpdates();
            Actor.RequestWalkStyle(WalkStyle.PetRun);

            if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, GetInteractionName(),
                                                                          allowCarryChild: false), pairedSocial: true, doCallOver: false))
            {
                if (Actor.IsCat)
                {
                    Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                    PouncePosture pouncePosture2 = Actor.Posture as PouncePosture;
                    if (pouncePosture2 != null)
                    {
                        pouncePosture2.ExitPounce();
                        Actor.PopPosture();
                    }
                }
                else
                {
                    Actor.UnrequestWalkStyle(WalkStyle.PetRun);
                }
                EndCommodityUpdates(false);
                return(false);
            }

            Actor.UnrequestWalkStyle(WalkStyle.PetRun);

            if (Actor.IsCat)
            {
                PouncePosture pouncePosture = PouncePosture.Create(Actor);
                pouncePosture.EnterPounce();
                Actor.Posture = pouncePosture;
            }

            StandardEntry(addToUseList: false);
            StartSocial("Fight Pet");
            ((SocialInteraction)LinkedInteractionInstance).Rejected = Rejected;
            mPetFightNoiseBroadcast = new ReactionBroadcaster(Actor, kPetFightLoudBroadcastParams,
                                                              FightBroadcastCallback);
            PetStartleBehavior.CheckForStartle(Actor, StartleType.Fight);
            EnterStateMachine("PetFight", "Enter", "x");
            SetActor("y", Target);
            AnimateSim("Loop Fight");
            // TODO: A fight should reduce fatigue
            InteractionTuning tuning = InteractionObjectPair.Tuning;

            if (tuning != null && tuning.mTradeoff != null)
            {
                using (List <CommodityChange> .Enumerator enumerator = tuning.mTradeoff.mOutputs.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        CommodityChange current = enumerator.Current;
                        if (current.Commodity == CommodityKind.CatScratch)
                        {
                            LinkedInteractionInstance.BeginCommodityUpdate(current, 1f);
                        }
                    }
                }
            }

            bool success = DoTimedLoop(RandomUtil.GetFloat(kPetFightTimeMinMax[0], kPetFightTimeMinMax[1]),
                                       ExitReason.Default);

            EndCommodityUpdates(success);
            Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives.GetMotiveValue(CommodityKind.Energy - 200));
            LinkedInteractionInstance.EndCommodityUpdates(success);
            bool actorWon = DoesActorWinFight();

            if (!actorWon)
            {
                AnimateSim("Swap");
                SetActor("x", Target);
                SetActor("y", Actor);
                skillTarget.wonFight(Actor, Target.LotCurrent == Target.LotHome);
                skillActor.lostFight(Target);
                skillTarget.AddPoints(200f, true, true);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightLose",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessageNegative);
            }
            else
            {
                skillActor.wonFight(Target, Actor.LotCurrent == Actor.LotHome);
                skillTarget.lostFight(Actor);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightWin",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessagePositive);
            }
            AnimateSim("Exit");

            if (Actor.IsCat)
            {
                Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                if (Actor.Posture is PouncePosture)
                {
                    Actor.PopPosture();
                }
            }
            else
            {
                Actor.UnrequestWalkStyle(WalkStyle.PetRun);
            }

            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Fight Pet", wasRecipient: false, wasAccepted: true, actorWon, CommodityTypes.Undefined));
            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Fight Pet", wasRecipient: true, wasAccepted: true, !actorWon, CommodityTypes.Undefined));

            if (mPetFightNoiseBroadcast != null)
            {
                mPetFightNoiseBroadcast.EndBroadcast();
                mPetFightNoiseBroadcast = null;
            }
            FinishSocial("Fight Pet", bApplySocialEffect: true);
            skillActor.StopSkillGain();
            skillTarget.StopSkillGain();
            FinishLinkedInteraction();
            WaitForSyncComplete();
            StandardExit(removeFromUseList: false);

            LikingChange();

            // Check for death conditions BEFORE new wounds assigned
            CheckForDeath(actorWon);
            AssignFightWounds();

            // If this is called from ChaseOffLot, then the target will flee if it loses
            if (!actorWon && actorRunOnLose && Actor.LotCurrent != Actor.LotHome)
            {
                Actor.PopPosture();
                Actor.RequestWalkStyle(WalkStyle.PetRun);
                MakeSimGoHome(Actor, false);
            }
            else if (actorWon && targetRunOnLose && Target.LotCurrent != Target.LotHome)
            {
                Target.PopPosture();
                if (Target.IsHuman)
                {
                    Target.RequestWalkStyle(WalkStyle.MeanChasedRun);
                }
                else
                {
                    Target.RequestWalkStyle(WalkStyle.PetRun);
                }
                MakeSimGoHome(Target, false);
            }

            return(success);
        }
Ejemplo n.º 6
0
        public static void PostDetentionLoop(GoToSchoolInRabbitHole ths, bool succeeded, bool detention, bool fieldTrip, AfterschoolActivity activity, bool hasAfterschoolActivity, ref InteractionInstance.InsideLoopFunction afterSchoolLoop)
        {
            try
            {
                School school = ths.Actor.School;

                ISchoolRabbitHole target = GetTarget(ths);

                bool flag5 = false;
                bool flag6 = false;
                if (!fieldTrip && !detention)
                {
                    if (hasAfterschoolActivity)
                    {
                        flag5 = true;
                    }
                    else if (!ths.Actor.IsInActiveHousehold && target.HasAfterschoolActivityToday)
                    {
                        flag5 = RandomUtil.CoinFlip();
                        flag6 = true;
                    }
                }

                if (!flag5)
                {
                    school.FinishWorking();

                    ths.EndCommodityUpdates(succeeded);
                    return;
                }

                CommodityChange fun = new CommodityChange(CommodityKind.Fun, 50, false, 25, OutputUpdateType.ContinuousFlow, false, false, UpdateAboveAndBelowZeroType.Either);

                ths.BeginCommodityUpdate(fun, 1);

                ths.mParticipatedInAfterschoolActivity = true;
                string str  = flag6 ? AfterschoolActivityType.ArtClub.ToString() : activity.CurrentActivityType.ToString();
                float  num3 = (school.DayLength + Career.kNumHoursEarlyCanShowUpForWork) + AfterschoolActivity.kAfterschoolActivityLength;

                string name = null;
                if (Localization.HasLocalizationString("Gameplay/Careers/AfterschoolActivity:" + str))
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Careers/AfterschoolActivity:" + str);
                }
                else
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Abstracts/Careers/AfterschoolActivity:" + str);
                }

                TimeOfDayStage stage2 = new TimeOfDayStage(name, school.CurLevel.FinishTime() + AfterschoolActivity.kAfterschoolActivityLength, num3);
                ths.Stages      = new List <Stage>(new Stage[] { stage2 });
                ths.ActiveStage = stage2;
                ths.SetAvailableTones(null);
                ths.Actor.RemoveExitReason(ExitReason.StageComplete);

                if (!flag6)
                {
                    activity.StartSkillGainForActivity(ths.Actor);

                    activity.StartAmbientSounds(ths.Actor, ths.Target);

                    if (!sCareerPerformAfterschoolPreLoop.Invoke <bool>(new object[] { ths, activity }))
                    {
                        if (activity.CurrentActivityType == AfterschoolActivityType.StudyClub)
                        {
                            school.AddHomeworkToStudent(false);
                            ths.mHomework = school.OwnersHomework;
                            if (ths.mHomework != null)
                            {
                                school.DidHomeworkInStudyClubToday = true;
                                ths.mHomework.PercentComplete      = 0f;
                                ths.mHomeworkCompletionRate        = ths.mHomework.GetCompletionRate(ths.Actor, false, true);
                            }
                        }
                    }

                    ths.mLastLTRUpdateDateAndTime = SimClock.CurrentTime();

                    afterSchoolLoop = sCareerPerformAfterschoolLoop.Invoke <InteractionInstance.InsideLoopFunction>(new object[] { ths, activity });
                    if (afterSchoolLoop == null)
                    {
                        afterSchoolLoop = ths.AfterschoolActivityLoopDelegate;
                    }
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
            }
        }
Ejemplo n.º 7
0
 private static void SaveCommodityChange(List <Guid> ids, ContextSession contextSession)
 {
     foreach (var item in GenegrateCommodityChangeDto(ids))
     {
         CommodityChange ChangedCommodity = new CommodityChange();
         ChangedCommodity.Id                 = Guid.NewGuid();
         ChangedCommodity.CommodityId        = item.CommodityId;
         ChangedCommodity.Name               = item.Name;
         ChangedCommodity.Code               = item.Code;
         ChangedCommodity.No_Number          = item.No_Number;
         ChangedCommodity.SubId              = item.SubId;
         ChangedCommodity.Price              = item.Price;
         ChangedCommodity.Stock              = item.Stock;
         ChangedCommodity.PicturesPath       = item.PicturesPath;
         ChangedCommodity.Description        = item.Description;
         ChangedCommodity.State              = item.State;
         ChangedCommodity.IsDel              = item.IsDel;
         ChangedCommodity.AppId              = item.AppId;
         ChangedCommodity.No_Code            = item.No_Code;
         ChangedCommodity.TotalCollection    = item.TotalCollection;
         ChangedCommodity.TotalReview        = item.TotalReview;
         ChangedCommodity.Salesvolume        = item.Salesvolume;
         ChangedCommodity.ModifiedOn         = item.ModifiedOn;
         ChangedCommodity.GroundTime         = item.GroundTime;
         ChangedCommodity.ComAttribute       = item.ComAttribute;
         ChangedCommodity.CategoryName       = item.CategoryName;
         ChangedCommodity.SortValue          = item.SortValue;
         ChangedCommodity.FreightTemplateId  = item.FreightTemplateId;
         ChangedCommodity.MarketPrice        = item.MarketPrice;
         ChangedCommodity.IsEnableSelfTake   = item.IsEnableSelfTake;
         ChangedCommodity.Weight             = item.Weight;
         ChangedCommodity.PricingMethod      = item.PricingMethod;
         ChangedCommodity.SaleAreas          = item.SaleAreas;
         ChangedCommodity.SharePercent       = item.SharePercent;
         ChangedCommodity.CommodityType      = item.CommodityType;
         ChangedCommodity.HtmlVideoPath      = item.HtmlVideoPath;
         ChangedCommodity.MobileVideoPath    = item.MobileVideoPath;
         ChangedCommodity.VideoPic           = item.VideoPic;
         ChangedCommodity.VideoName          = item.VideoName;
         ChangedCommodity.ScorePercent       = item.ScorePercent;
         ChangedCommodity.Duty               = item.Duty;
         ChangedCommodity.SpreadPercent      = item.SpreadPercent;
         ChangedCommodity.ScoreScale         = item.ScoreScale;
         ChangedCommodity.TaxRate            = item.TaxRate;
         ChangedCommodity.TaxClassCode       = item.TaxClassCode;
         ChangedCommodity.Unit               = item.Unit;
         ChangedCommodity.InputRax           = item.InputRax;
         ChangedCommodity.Barcode            = item.Barcode;
         ChangedCommodity.JDCode             = item.JDCode;
         ChangedCommodity.CostPrice          = item.CostPrice;
         ChangedCommodity.IsAssurance        = item.IsAssurance;
         ChangedCommodity.TechSpecs          = item.TechSpecs;
         ChangedCommodity.SaleService        = item.SaleService;
         ChangedCommodity.IsReturns          = item.IsReturns;
         ChangedCommodity.ServiceSettingId   = item.ServiceSettingId;
         ChangedCommodity.Type               = item.Type;
         ChangedCommodity.YJCouponActivityId = item.YJCouponActivityId;
         ChangedCommodity.YJCouponType       = item.YJCouponType;
         ChangedCommodity.SubOn              = item.SubOn;
         ChangedCommodity.ModifiedId         = Guid.Empty;
         ChangedCommodity.AuditState         = 0;
         ChangedCommodity.EntityState        = EntityState.Added;
         contextSession.SaveObject(ChangedCommodity);
     }
 }
Ejemplo n.º 8
0
 public CommodityChangeOption(InteractionTuning tuning, CommodityChange change)
     : base(CommoditiesEx.GetMotiveLocalizedName(change.Commodity))
 {
     mTuning = tuning;
     mChange = change;
 }
        public static void PostDetentionLoop(GoToSchoolInRabbitHole ths, bool succeeded, bool detention, bool fieldTrip, AfterschoolActivity activity, bool hasAfterschoolActivity, ref InteractionInstance.InsideLoopFunction afterSchoolLoop)
        {
            try
            {
                School school = ths.Actor.School;

                ISchoolRabbitHole target = GetTarget(ths);

                bool flag5 = false;
                bool flag6 = false;
                if (!fieldTrip && !detention)
                {
                    if (hasAfterschoolActivity)
                    {
                        flag5 = true;
                    }
                    else if (!ths.Actor.IsInActiveHousehold && target.HasAfterschoolActivityToday)
                    {
                        flag5 = RandomUtil.CoinFlip();
                        flag6 = true;
                    }
                }

                if (!flag5)
                {
                    school.FinishWorking();

                    ths.EndCommodityUpdates(succeeded);
                    return;
                }

                CommodityChange fun = new CommodityChange(CommodityKind.Fun, 50, false, 25, OutputUpdateType.ContinuousFlow, false, false, UpdateAboveAndBelowZeroType.Either);

                ths.BeginCommodityUpdate(fun, 1);

                ths.mParticipatedInAfterschoolActivity = true;
                string str = flag6 ? AfterschoolActivityType.ArtClub.ToString() : activity.CurrentActivityType.ToString();
                float num3 = (school.DayLength + Career.kNumHoursEarlyCanShowUpForWork) + AfterschoolActivity.kAfterschoolActivityLength;

                string name = null;
                if (Localization.HasLocalizationString("Gameplay/Careers/AfterschoolActivity:" + str))
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Careers/AfterschoolActivity:" + str);
                }
                else
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Abstracts/Careers/AfterschoolActivity:" + str);
                }

                TimeOfDayStage stage2 = new TimeOfDayStage(name, school.CurLevel.FinishTime() + AfterschoolActivity.kAfterschoolActivityLength, num3);
                ths.Stages = new List<Stage>(new Stage[] { stage2 });
                ths.ActiveStage = stage2;
                ths.SetAvailableTones(null);
                ths.Actor.RemoveExitReason(ExitReason.StageComplete);

                if (!flag6)
                {
                    activity.StartSkillGainForActivity(ths.Actor);

                    activity.StartAmbientSounds(ths.Actor, ths.Target);

                    if (!sCareerPerformAfterschoolPreLoop.Invoke<bool>(new object[] { ths, activity }))
                    {
                        if (activity.CurrentActivityType == AfterschoolActivityType.StudyClub)
                        {
                            school.AddHomeworkToStudent(false);
                            ths.mHomework = school.OwnersHomework;
                            if (ths.mHomework != null)
                            {
                                school.DidHomeworkInStudyClubToday = true;
                                ths.mHomework.PercentComplete = 0f;
                                ths.mHomeworkCompletionRate = ths.mHomework.GetCompletionRate(ths.Actor, false, true);
                            }
                        }
                    }

                    ths.mLastLTRUpdateDateAndTime = SimClock.CurrentTime();

                    afterSchoolLoop = sCareerPerformAfterschoolLoop.Invoke<InteractionInstance.InsideLoopFunction>(new object[] { ths, activity });
                    if (afterSchoolLoop == null)
                    {
                        afterSchoolLoop = ths.AfterschoolActivityLoopDelegate;
                    }
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 插入改动商品信息
        /// </summary>
        /// <param name="commodityAndCategoryDTO">商品扩展实体</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveCommodityChangeExt(System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> commodity)
        {
            try
            {
                if (commodity == null)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "参数不能为空"
                    });
                }
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                var            ComIds         = commodity.Select(s => s.CommodityId).ToList();
                var            ComList        = CommodityChange.ObjectSet().Where(p => ComIds.Contains(p.CommodityId)).GroupBy(p => p.CommodityId).Select(p => p.OrderByDescending(s => s.ModifiedOn).FirstOrDefault()).ToList();

                var LoginUserID = this.ContextDTO.LoginUserID;
                foreach (var item in commodity.Distinct())
                {
                    var             CommodityList = ComList.FirstOrDefault(p => p.CommodityId == item.CommodityId);
                    System.TimeSpan t3            = TimeSpan.Parse("0");
                    if (CommodityList != null)
                    {
                        var ModifyTime = CommodityList.ModifiedOn;
                        t3 = item.ModifiedOn - ModifyTime;
                    }
                    if (t3.TotalSeconds >= 5 || CommodityList == null)//时间间隔超过五秒  避免数据重复
                    {
                        CommodityChange ChangedCommodity = CommodityChange.CreateCommodityChange();
                        ChangedCommodity.Id                 = Guid.NewGuid();
                        ChangedCommodity.CommodityId        = item.CommodityId;
                        ChangedCommodity.Name               = item.Name;
                        ChangedCommodity.Code               = item.Code;
                        ChangedCommodity.No_Number          = item.No_Number;
                        ChangedCommodity.SubId              = item.SubId;
                        ChangedCommodity.Price              = item.Price;
                        ChangedCommodity.Stock              = item.Stock;
                        ChangedCommodity.PicturesPath       = item.PicturesPath;
                        ChangedCommodity.State              = item.State;
                        ChangedCommodity.IsDel              = item.IsDel;
                        ChangedCommodity.Description        = "";
                        ChangedCommodity.AppId              = item.AppId;
                        ChangedCommodity.No_Code            = item.No_Code;
                        ChangedCommodity.TotalCollection    = item.TotalCollection;
                        ChangedCommodity.TotalReview        = item.TotalReview;
                        ChangedCommodity.Salesvolume        = item.Salesvolume;
                        ChangedCommodity.ModifiedOn         = DateTime.Now;
                        ChangedCommodity.GroundTime         = item.GroundTime;
                        ChangedCommodity.ComAttribute       = item.ComAttribute;
                        ChangedCommodity.CategoryName       = item.CategoryName;
                        ChangedCommodity.SortValue          = item.SortValue;
                        ChangedCommodity.FreightTemplateId  = item.FreightTemplateId;
                        ChangedCommodity.MarketPrice        = item.MarketPrice;
                        ChangedCommodity.IsEnableSelfTake   = item.IsEnableSelfTake;
                        ChangedCommodity.Weight             = item.Weight;
                        ChangedCommodity.PricingMethod      = item.PricingMethod;
                        ChangedCommodity.SaleAreas          = item.SaleAreas;
                        ChangedCommodity.SharePercent       = item.SharePercent;
                        ChangedCommodity.CommodityType      = item.CommodityType;
                        ChangedCommodity.HtmlVideoPath      = item.HtmlVideoPath;
                        ChangedCommodity.MobileVideoPath    = item.MobileVideoPath;
                        ChangedCommodity.VideoPic           = item.VideoPic;
                        ChangedCommodity.VideoName          = item.VideoName;
                        ChangedCommodity.ScorePercent       = item.ScorePercent;
                        ChangedCommodity.Duty               = item.Duty;
                        ChangedCommodity.SpreadPercent      = item.SpreadPercent;
                        ChangedCommodity.ScoreScale         = item.ScoreScale;
                        ChangedCommodity.TaxRate            = item.TaxRate;
                        ChangedCommodity.TaxClassCode       = item.TaxClassCode;
                        ChangedCommodity.Unit               = item.Unit;
                        ChangedCommodity.InputRax           = item.InputRax;
                        ChangedCommodity.Barcode            = item.Barcode;
                        ChangedCommodity.JDCode             = item.JDCode;
                        ChangedCommodity.CostPrice          = item.CostPrice;
                        ChangedCommodity.IsAssurance        = item.IsAssurance;
                        ChangedCommodity.IsReturns          = item.IsReturns;
                        ChangedCommodity.ServiceSettingId   = item.ServiceSettingId;
                        ChangedCommodity.Type               = item.Type;
                        ChangedCommodity.YJCouponActivityId = item.YJCouponActivityId;
                        ChangedCommodity.YJCouponType       = item.YJCouponType;
                        ChangedCommodity.SubOn              = item.SubOn;
                        ChangedCommodity.ModifiedId         = LoginUserID;
                        ChangedCommodity.AuditState         = 0;
                        ChangedCommodity.SubTime            = DateTime.Now;
                        contextSession.SaveObject(ChangedCommodity);
                    }
                }
                int count = contextSession.SaveChanges();
                LogHelper.Info("数据同步到商品变动明细报表保存条数: " + count + ",DateTime: " + DateTime.Now);
                return(new ResultDTO {
                    ResultCode = 1, Message = "保存成功", isSuccess = true
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("保存商品变动数据异常"), ex);
                return(new ResultDTO {
                    ResultCode = 0, Message = "保存失败", isSuccess = false
                });
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取商品信息变更信息
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> GetCommodityChangeList(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search)
        {
            try
            {
                var query = CommodityChange.ObjectSet().Where(p => Search.Appids.Contains(p.AppId)).AsQueryable();
                #region  查询条件
                //根据供应商
                if (Search.AppidsList.Count > 0)
                {
                    query = query.Where(p => Search.AppidsList.Contains(p.AppId));
                }
                //商铺名称
                if (Search.AppId != Guid.Empty)
                {
                    query = query.Where(p => p.AppId == Search.AppId);
                }
                //商品名称
                if (!string.IsNullOrEmpty(Search.Name))
                {
                    query = query.Where(p => Search.Name.Contains(p.Name) || p.Name.Contains(Search.Name));
                }
                //备注编码
                if (!string.IsNullOrEmpty(Search.JDCode))
                {
                    query = query.Where(p => p.JDCode == Search.JDCode);
                }
                //商品条形码
                if (!string.IsNullOrEmpty(Search.Barcode))
                {
                    query = query.Where(p => p.Barcode == Search.Barcode);
                }
                //发布人
                if (Search.SubId != Guid.Empty)
                {
                    query = query.Where(p => p.SubId == Search.SubId);
                }
                if (!string.IsNullOrEmpty(Search.SubStarTime))
                {
                    var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    StartTime = DateTime.Parse(Search.SubStarTime);
                    query     = query.Where(p => p.SubOn >= StartTime);
                }
                if (!string.IsNullOrEmpty(Search.SubEndTime))
                {
                    var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    EndTime = DateTime.Parse(Search.SubEndTime).AddDays(1);
                    query   = query.Where(p => p.SubOn <= EndTime);
                }
                if (Search.ModifiedId != Guid.Empty)
                {
                    query = query.Where(p => p.ModifiedId == Search.ModifiedId);
                }
                if (!string.IsNullOrEmpty(Search.ModStarTime))
                {
                    var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    StartTime = DateTime.Parse(Search.ModStarTime);
                    query     = query.Where(p => p.ModifiedOn >= StartTime);
                }
                if (!string.IsNullOrEmpty(Search.ModEndTime))
                {
                    var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    EndTime = DateTime.Parse(Search.ModEndTime).AddDays(1);
                    query   = query.Where(p => p.ModifiedOn <= EndTime);
                }
                if (Search.State != -1)
                {
                    if (Search.State == 3)
                    {   //已删除的数据
                        query = query.Where(p => p.IsDel == true);
                    }
                    else
                    {
                        query = query.Where(p => p.State == Search.State && p.IsDel == false);
                    }
                }
                #endregion
                List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> result = (from n in query
                                                                                    select new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO
                {
                    Id = n.Id,
                    CommodityId = n.CommodityId,
                    AppId = n.AppId,
                    Barcode = n.Barcode,
                    Type = n.Type,
                    YJCouponActivityId = n.YJCouponActivityId,
                    YJCouponType = n.YJCouponType,
                    No_Code = n.No_Code,
                    JDCode = n.JDCode,                                                                        //备注编码
                    Name = n.Name,
                    MarketPrice = n.MarketPrice,
                    Price = n.Price,
                    CostPrice = n.CostPrice,
                    TaxClassCode = n.TaxClassCode,
                    InputRax = n.InputRax,
                    TaxRate = n.TaxRate,
                    ComAttribute = n.ComAttribute,
                    Unit = n.Unit,
                    SubId = n.SubId,
                    SubOn = n.SubOn,
                    ModifiedId = n.ModifiedId,
                    ModifiedOn = n.ModifiedOn,
                    State = n.State,
                    IsDel = n.IsDel
                }).OrderByDescending(p => p.ModifiedOn).ToList();
                if (result.Count() > 0)
                {
                    if (result.Count() > 0)
                    {
                        //获取商铺名称
                        List <Guid> appIds = (from it in result select it.AppId).Distinct().ToList();
                        Dictionary <Guid, string> listApps = APPSV.GetAppNameListByIds(appIds); //获取商铺名称

                        //获取供应商名称
                        var SupplierList = Supplier.ObjectSet().Where(p => appIds.Contains(p.AppId)).Select(s => new { s.AppId, s.SupplierName }).Distinct().ToList();

                        //获取提交人名称
                        List <Guid> SubId    = (from n in query where n.SubId != null select n.SubId).Distinct().ToList();
                        List <Guid> ModId    = (from n in query where n.ModifiedId != null select n.ModifiedId).Distinct().ToList();
                        List <Guid> userid   = SubId.Union(ModId).Distinct().ToList();
                        var         Userinfo = CBCSV.GetUserNameAndCodes(userid);

                        foreach (var item in result)
                        {
                            //获取提交人名称
                            var NameAndCodes = Userinfo[item.SubId];
                            item.SubName = NameAndCodes.Item1;
                            item.SubCode = NameAndCodes.Item2;
                            //获取供应商名称
                            var SupplierName = SupplierList.Where(p => p.AppId == item.AppId).Select(s => s.SupplierName).FirstOrDefault();
                            if (!string.IsNullOrEmpty(SupplierName))
                            {
                                item.SupplierName = SupplierName;
                            }
                            //获取商铺名称
                            if (listApps.ContainsKey(item.AppId))
                            {
                                var listAppName = listApps[item.AppId];
                                if (!String.IsNullOrEmpty(listAppName))
                                {
                                    item.AppName = listAppName;
                                }
                            }
                            //获取修改人名称
                            if (item.ModifiedId != new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9") && item.ModifiedId != null)
                            {
                                Guid MId = item.ModifiedId ?? new Guid("00000000-0000-0000-0000-000000000000");
                                NameAndCodes      = Userinfo[MId];
                                item.ModifiedName = NameAndCodes.Item1;
                                item.ModifiedCode = NameAndCodes.Item2;
                            }
                            else if (item.ModifiedId == new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9"))
                            {
                                item.ModifiedName = "系统自动";
                                item.ModifiedCode = "京东同步";
                            }
                            else
                            {
                                item.ModifiedName = "";
                                item.ModifiedCode = "";
                            }
                            //格式化状态
                            if (!item.IsDel)
                            {
                                if (item.State == 0)
                                {
                                    item.StateName = "在售中";
                                }
                                else
                                {
                                    item.StateName = "已下架";
                                }
                            }
                            else
                            {
                                item.StateName = "已删除";
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Jinher.JAP.Common.Loging.LogHelper.Error(string.Format("根据搜索条件获取变动商品表异常。"), ex);
                return(null);
            }
        }