static bool Prefix(ref ImmediateRankUIPanel __instance, ref RelativeScoreAndImmediateRankCounter ____relativeScoreAndImmediateRankCounter,
                           ref RankModel.Rank ____prevImmediateRank, ref float ____prevRelativeScore, ref TextMeshProUGUI ____rankText,
                           ref TextMeshProUGUI ____relativeScoreText)
        {
            if (!CountersController.settings.Enabled)
            {
                return(true);                                      //Dont use Score Counters decimal precision if the plugin is disabled
            }
            if (model == null)
            {
                model = CountersController.settings.scoreConfig;
            }
            RankModel.Rank rank = ____relativeScoreAndImmediateRankCounter.immediateRank;
            if (rank != ____prevImmediateRank)
            {
                ____rankText.text     = model.Mode != ICounterMode.BaseGame ? $"\n{RankModel.GetRankName(rank)}" : RankModel.GetRankName(rank);
                ____prevImmediateRank = rank;
            }
            float score = ____relativeScoreAndImmediateRankCounter.relativeScore;

            if (Mathf.Abs(____prevRelativeScore - score) >= 0.001f)
            {
                float roundedScore = (float)Math.Round((decimal)score * 100, model.DecimalPrecision);
                ____relativeScoreText.text = $"{roundedScore.ToString($"F{model.DecimalPrecision}")}%";
            }
            return(false);
        }
 /// <summary>
 /// 添加客户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int InsertCustomerInfo(CustomerModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         int flag = dal.InsertCustomerInfo(model);
         BeansRecordsModel model2 = null;
         if (flag > 0)
         {
             //如果相等于,表示当前是盟主添加客户信息
             if (model.BelongOne == model.BelongTwo)
             {
                 //获取积分奖励配置
                 ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                 using (var dal1 = FactoryDispatcher.UserFactory())
                 {
                     //盟友提交客户信息,盟主奖励
                     if (scoreCfg.SubmitCustomerToMainScore2 > 0 && dal1.addUserIntegral(model.BelongOne, scoreCfg.SubmitCustomerToMainScore2) > 0)
                     {
                         model2            = new BeansRecordsModel();
                         model2.Amount     = scoreCfg.SubmitCustomerToMainScore1;
                         model2.UserId     = model.BelongTwo;
                         model2.LogType    = 1;
                         model2.Income     = 1;
                         model2.Remark     = "客户信息奖励";
                         model2.OrderId    = "";
                         model2.CreateTime = DateTime.Now;
                     }
                 }
             }
         }
         return(flag);
     }
 }
Exemple #3
0
        /// <summary>
        ///   盟友申请审核
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="id"></param>
        /// <param name="status">1成功2拒绝</param>
        /// <returns></returns>
        public static bool AllyApplyAudit(int userId, int id, int status, ref ApiStatusCode code)
        {
            using (var dal = FactoryDispatcher.UserFactory())
            {
                ApplyFriendModel model = dal.getApplyFriendModel(id);
                if (model == null || model.UserId != userId)
                {
                    code = ApiStatusCode.操作失败;
                    return(false);
                }

                if (status == 1)
                {
                    //using (TransactionScope scope = new TransactionScope())
                    //{
                    dal.updateApplyFriendStatus(id, 1);
                    UserRegisterModel register = new UserRegisterModel();
                    register.belongOne     = userId;
                    register.loginName     = model.Mobile;
                    register.loginPassword = model.Password;
                    register.mobile        = model.Mobile;
                    register.nickname      = model.NickName;
                    register.ShopId        = dal.getUserShopId(userId);
                    register.BelongShopId  = ShopLogic.GetBelongShopId(register.ShopId);
                    register.storeId       = ConstConfig.storeId;
                    register.UserIdentity  = 0;
                    register.username      = model.UserName;
                    register.userGender    = model.Sex == 1 ? "M" : "F";
                    if (dal.AddUserInfo(register) > 0)
                    {
                        masterUpdate(userId);

                        //获取积分奖励配置
                        ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                        //添加盟主创建订单,奖励积分
                        if (scoreCfg.CreateOrderScore > 0 && dal.addUserIntegral(userId, scoreCfg.CreateOrderScore) > 0)
                        {
                            BeansRecordsModel model2 = new BeansRecordsModel();
                            model2.Amount     = scoreCfg.CreateOrderScore;
                            model2.UserId     = userId;
                            model2.LogType    = 1;
                            model2.Income     = 1;
                            model2.Remark     = "邀请盟友奖励";
                            model2.OrderId    = "";
                            model2.CreateTime = DateTime.Now;
                            dal.AddBeansRecords(model2);
                        }
                    }
                    //    scope.Complete();
                    //}
                }
                else if (status == 2)
                {
                    dal.updateApplyFriendStatus(id, 2);
                }
            }
            return(true);
        }
        public override void InstallBindings()
        {
            MainConfigModel mainConfig = Plugin.MainConfig;

            hudConfig = Container.Resolve <HUDConfigModel>();
            dataModel = Container.Resolve <PlayerDataModel>();

            if (!mainConfig.Enabled)
            {
                return;
            }

            /// LOADING IMPORTANT SHIT LIKE CANVASES AND STUFF ///
            Container.Bind <CanvasUtility>().AsSingle();

            Container.Bind <NoteCountProcessor>().To <GenericNoteCountProcessor>().AsSingle();

            /// LOADING COUNTERS ///
            Plugin.Logger.Notice("Loading counters...");

            AddCounter <MissedConfigModel, MissedCounter>();
            AddCounter <NoteConfigModel, NotesCounter>();

            if (mainConfig.ProgressConfig.Mode != ProgressMode.BaseGame)
            {
                AddCounter <ProgressConfigModel, ProgressCounter>();
            }
            else
            {
                AddCounter <ProgressConfigModel, ProgressBaseGameCounter>();
            }

            AddCounter <ScoreConfigModel, ScoreCounter>();
            AddCounter <CutConfigModel, CutCounter>();
            AddCounter <FailConfigModel, FailCounter>();
            AddCounter <NotesLeftConfigModel, NotesLeftCounter>();
            AddCounter <SpeedConfigModel, SpeedCounter>();
            AddCounter <SpinometerConfigModel, Spinometer>();


            AddCounter <PBConfigModel, PBCounter>((settings) => {
                ScoreConfigModel scoreConfig = Container.Resolve <ScoreConfigModel>();
                HUDCanvas canvasSettings     = scoreConfig.CanvasID == -1 ? hudConfig.MainCanvasSettings : hudConfig.OtherCanvasSettings[scoreConfig.CanvasID];
                return(scoreConfig.Enabled && settings.UnderScore && (dataModel.playerData.playerSpecificSettings.noTextsAndHuds ? canvasSettings.IgnoreNoTextAndHUDOption : true));
            });

            foreach (Custom.CustomCounter customCounter in Plugin.LoadedCustomCounters.Values)
            {
                AddCustomCounter(customCounter, customCounter.CounterType);
            }

            /// LOADING BROADCASTERS WITH BROADCAST IN-GAME EVENTS TO COUNTERS AND STUFF ///
            Container.BindInterfacesAndSelfTo <CounterEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <NoteEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <ScoreEventBroadcaster>().AsSingle().NonLazy();
            Plugin.Logger.Notice("Counters loaded!");
        }
Exemple #5
0
        private static bool ShouldEnableScorePanel(bool original)
        {
            if (!GameplayCoreSceneSetupPatch.IsOverridingBaseGameHUD)
            {
                return(original);
            }
            ScoreConfigModel scoreConfig = Plugin.MainConfig.ScoreConfig;

            return(original || scoreConfig.Enabled);
        }
Exemple #6
0
        private static bool ShouldEnableScorePanel(bool original)
        {
            if (!isOverriding)
            {
                return(original);
            }
            ScoreConfigModel scoreConfig = Plugin.MainConfig.ScoreConfig;

            return(original || scoreConfig.Enabled);
        }
Exemple #7
0
        public static bool ShouldSkip(bool original)
        {
            HUDConfigModel      hudConfig = Plugin.MainConfig.HUDConfig;
            ProgressConfigModel progress  = Plugin.MainConfig.ProgressConfig;
            ScoreConfigModel    score     = Plugin.MainConfig.ScoreConfig;

            isOverriding = original && (
                (progress.Enabled && progress.Mode == ProgressMode.BaseGame && CheckIgnoreOption(hudConfig, progress)) ||
                (score.Enabled && CheckIgnoreOption(hudConfig, score)));
            return(isOverriding);
        }
        public override void InstallBindings()
        {
            MainConfigModel mainConfig = Plugin.MainConfig;

            if (!mainConfig.Enabled)
            {
                return;
            }

            /// LOADING IMPORTANT SHIT LIKE CANVASES AND STUFF ///
            Container.Bind <CanvasUtility>().AsSingle();

            Container.Bind <NoteCountProcessor>().To <GenericNoteCountProcessor>().AsSingle();

            /// LOADING COUNTERS ///
            Plugin.Logger.Notice("Loading counters...");

            AddCounter <MissedConfigModel, MissedCounter>();
            AddCounter <NoteConfigModel, NotesCounter>();

            if (mainConfig.ProgressConfig.Mode != ProgressMode.BaseGame)
            {
                AddCounter <ProgressConfigModel, ProgressCounter>();
            }
            else
            {
                AddCounter <ProgressConfigModel, ProgressBaseGameCounter>();
            }

            AddCounter <ScoreConfigModel, ScoreCounter>();
            AddCounter <CutConfigModel, CutCounter>();
            AddCounter <FailConfigModel, FailCounter>();
            AddCounter <NotesLeftConfigModel, NotesLeftCounter>();
            AddCounter <SpeedConfigModel, SpeedCounter>();
            AddCounter <SpinometerConfigModel, Spinometer>();

            AddCounter <PBConfigModel, PBCounter>((settings) => {
                ScoreConfigModel scoreConfig = Container.Resolve <ScoreConfigModel>();
                HUDCanvas canvasSettings     = GrabCanvasForCounter(scoreConfig);
                return(scoreConfig.Enabled && settings.UnderScore && (dataModel.playerData.playerSpecificSettings.noTextsAndHuds ? canvasSettings.IgnoreNoTextAndHUDOption : true));
            });

            InstallCustomCounters();

            if (mainConfig.AprilFoolsTomfoolery && mainConfig.IsAprilFools)
            {
                Container.BindInterfacesAndSelfTo <AprilFools>().AsSingle().NonLazy();
            }

            /// LOADING BROADCASTERS WITH BROADCAST IN-GAME EVENTS TO COUNTERS AND STUFF ///
            Container.BindInterfacesAndSelfTo <CounterEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <NoteEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <ScoreEventBroadcaster>().AsSingle().NonLazy();
        }
Exemple #9
0
 void Awake()
 {
     settings = CountersController.settings.scoreConfig;
     if (settings.UseOld && gameObject.name != "ScorePanel")
     {
         StartCoroutine(YeetToBaseCounter());
     }
     else if (!settings.UseOld)
     {
         StartCoroutine(WaitForLoad());
     }
 }
Exemple #10
0
        public static bool ShouldSkip(PlayerSpecificSettings specificSettings, DiContainer container)
        {
            HUDConfigModel      hudConfig = container.Resolve <HUDConfigModel>();
            ProgressConfigModel progress  = container.Resolve <ProgressConfigModel>();
            ScoreConfigModel    score     = container.Resolve <ScoreConfigModel>();
            bool result = specificSettings.noTextsAndHuds && !(
                (progress.Enabled && progress.Mode == ProgressMode.BaseGame && CheckIgnoreOption(hudConfig, progress)) ||
                (score.Enabled && CheckIgnoreOption(hudConfig, score)));

            IsOverridingBaseGameHUD = specificSettings.noTextsAndHuds && !result;
            return(result);
        }
Exemple #11
0
 void Awake()
 {
     settings         = CountersController.settings.scoreConfig;
     decimalPrecision = settings.DecimalPrecision;
     if (gameObject.name == "ScorePanel")
     {
         PreInit();
     }
     else
     {
         StartCoroutine(YeetToBaseCounter());
     }
 }
Exemple #12
0
        static bool Prefix(ref ImmediateRankUIPanel __instance, ref RelativeScoreAndImmediateRankCounter ____relativeScoreAndImmediateRankCounter,
                           ref RankModel.Rank ____prevImmediateRank, ref float ____prevRelativeScore, ref TextMeshProUGUI ____rankText,
                           ref TextMeshProUGUI ____relativeScoreText)
        {
            if (!CountersController.settings.Enabled)
            {
                return(true);                                      //Dont use Score Counters decimal precision if the plugin is disabled
            }
            if (model == null)
            {
                model = CountersController.settings.scoreConfig;
            }
            RankModel.Rank rank = ____relativeScoreAndImmediateRankCounter.immediateRank;
            if (rank != ____prevImmediateRank)
            {
                ____rankText.text     = model.Mode != ICounterMode.BaseGame ? $"\n{RankModel.GetRankName(rank)}" : RankModel.GetRankName(rank);
                ____prevImmediateRank = rank;
                //I am moving this code down here so that it only runs if the rank changes instead of every time the game refreshes the UI.
                //Because of how cosmic brain Beat Games is, this code should run on game startup, because SSS != SS, so should work fine.
                if (model.CustomRankColors)
                {
                    string color = "#FFFFFF";                //Blank white shall be used for the default color in case like some SSS shit happens
                    switch (RankModel.GetRankName(rank))     //Using PogU switch case instead of Pepega If chain
                    {
                    case "SS": color = model.SSColor; break; //Even compressing this shit down to one liners, look at me!

                    case "S": color = model.SColor; break;

                    case "A": color = model.AColor; break;

                    case "B": color = model.BColor; break;

                    case "C": color = model.CColor; break;

                    case "D": color = model.DColor; break;

                    case "E": color = model.EColor; break;
                    }
                    ColorUtility.TryParseHtmlString(color, out Color RankColor); //converts config hex color to unity RGBA value
                    ____rankText.color = RankColor;                              //sets color of ranktext
                }
            }
            float score = ____relativeScoreAndImmediateRankCounter.relativeScore;

            if (Mathf.Abs(____prevRelativeScore - score) >= 0.001f)
            {
                float roundedScore = (float)Math.Round((decimal)score * 100, model.DecimalPrecision);
                ____relativeScoreText.text = $"{roundedScore.ToString($"F{model.DecimalPrecision}")}%";
            }
            return(false);
        }
Exemple #13
0
        /// <summary>
        /// 获取积分奖励配置
        /// </summary>
        /// <returns></returns>
        public static ScoreConfigModel GetScoreConfig()
        {
            ScoreConfigModel   result = new ScoreConfigModel();
            List <ConfigModel> lst    = GetConfigList();

            if (lst == null)
            {
                return(result);
            }

            foreach (var item in lst)
            {
                //
                if (item.Code.Equals("CreateOrderScore"))
                {
                    result.CreateOrderScore = string.IsNullOrEmpty(item.Value) ? 0 : Convert.ToInt32(item.Value);
                }

                if (item.Code.Equals("InviteScore"))
                {
                    result.InviteScore = string.IsNullOrEmpty(item.Value) ? 0 : Convert.ToInt32(item.Value);
                }

                if (item.Code.Equals("SubmitCustomerToAllyScore"))
                {
                    result.SubmitCustomerToAllyScore = string.IsNullOrEmpty(item.Value) ? 0 : Convert.ToInt32(item.Value);
                }

                if (item.Code.Equals("SubmitCustomerToMainScore1"))
                {
                    result.SubmitCustomerToMainScore1 = string.IsNullOrEmpty(item.Value) ? 0 : Convert.ToInt32(item.Value);
                }

                if (item.Code.Equals("SubmitCustomerToMainScore2"))
                {
                    result.SubmitCustomerToMainScore2 = string.IsNullOrEmpty(item.Value) ? 0 : Convert.ToInt32(item.Value);
                }
            }
            return(result);
        }
Exemple #14
0
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="status">审核状态 1已同意  2已拒绝 3未生成订单  4已生成订单,5已失效</param>
        /// <param name="userId">操作人ID(此方法只有盟主操作)</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool UpdateStatus(int customerId, int status, int userId)
        {
            try
            {
                using (var dal = FactoryDispatcher.CustomerFactory())
                {
                    bool flag = dal.UpdateStatus(customerId, status == 1 ? 3 : status, userId);

                    //如果客户审核同意
                    if (flag && status == 1)
                    {
                        //修改审核成功时间
                        dal.UpdateAuditTime(customerId);

                        var model = dal.GetModel(customerId);
                        if (model != null && model.BelongOne > 0)
                        {
                            //添加用户的客户量
                            UserLogic.AddUserCustomerAmount(model.BelongOne);
                            if (model.BelongOne != model.BelongTwo)
                            {
                                UserLogic.AddUserCustomerAmount(model.BelongTwo);
                            }


                            var shopData = ShopLogic.GetShopModel(model.ShopId);
                            RewardsSettingModel rewardSettingModel = null;
                            //判断当前客户是否所属分店
                            if (shopData != null && shopData.ShopType == 2)
                            {
                                rewardSettingModel = UserLogic.GetRewardModel(model.ShopId);
                            }

                            using (var dal1 = FactoryDispatcher.UserFactory())
                            {
                                BeansRecordsModel model2 = null;
                                if (rewardSettingModel != null && rewardSettingModel.CustomerReward > 0)
                                {
                                    //给盟友加盟豆
                                    UserLogic.addUserMoney(model.BelongOne, rewardSettingModel.CustomerReward);
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = rewardSettingModel.CustomerReward;
                                    model2.UserId     = model.BelongOne;
                                    model2.LogType    = 0;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = model.ID.ToString();
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                                //获取积分奖励配置
                                ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                                //审核盟友提交的客户信息
                                if (scoreCfg.SubmitCustomerToAllyScore > 0 && dal1.addUserIntegral(model.BelongOne, scoreCfg.SubmitCustomerToAllyScore) > 0)
                                {
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = scoreCfg.SubmitCustomerToAllyScore;
                                    model2.UserId     = model.BelongOne;
                                    model2.LogType    = 1;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = "";
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                                //盟友提交客户信息,盟主奖励
                                if (scoreCfg.SubmitCustomerToMainScore1 > 0 && dal1.addUserIntegral(model.BelongTwo, scoreCfg.SubmitCustomerToMainScore1) > 0)
                                {
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = scoreCfg.SubmitCustomerToMainScore1;
                                    model2.UserId     = model.BelongTwo;
                                    model2.LogType    = 1;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = "";
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                            }
                        }
                    }
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("UpdateStatus:message:{0},StackTrace:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }
Exemple #15
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="shopId">The shop identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="mobile">The mobile.</param>
        /// <param name="address">The address.</param>
        /// <param name="cashNo">The cash no.</param>
        /// <param name="memo">The memo.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="apiCode">The API code.</param>
        /// <returns>true if XXXX, false otherwise.</returns>
        public static bool saveOrder(int userId, int shopId, string userName, string mobile, string address, string cashNo, string memo, string filename, string fileName2, string fileName3, string fileName4, string fileName5, int cid, ref ApiStatusCode apiCode)
        {
            try
            {
                OrderModel model = new OrderModel();
                model.orderId     = createOrderNo(userId);
                model.UserId      = userId;
                model.Ct_BelongId = userId;
                model.orderTime   = DateTime.Now;
                model.Memo        = memo;
                model.OrderStatus = 0;
                model.OrderImg    = filename;
                model.OrderImg2   = fileName2;
                model.OrderImg3   = fileName3;
                model.OrderImg4   = fileName4;
                model.OrderImg5   = fileName5;
                model.SuccessImg  = model.SuccessImg2 = model.SuccessImg3 = model.SuccessImg4 = model.SuccessImg5 = "";
                model.Ct_Name     = userName;
                model.Ct_Mobile   = mobile;
                model.Ct_Address  = address;
                model.FianlAmount = 0;
                model.CreateTime  = DateTime.Now;

                //判断订单是否使用优惠券
                CashCouponLogModel coupon = null;
                int cashUserId            = 0;
                using (var dal = FactoryDispatcher.CouponFactory())
                {
                    if (!string.IsNullOrEmpty(cashNo))
                    {
                        coupon = dal.getEnableCashCouponLogModel(mobile, cashNo);
                        if (coupon != null && coupon.ID > 0)
                        {
                            if (coupon.ShopId != shopId)
                            {
                                apiCode = ApiStatusCode.非本店现金券;
                                return(false);
                            }
                            if (coupon.IsUse != 0)
                            {
                                apiCode = ApiStatusCode.现金券已使用;
                                return(false);
                            }
                            model.CashCouponAmount = coupon.Money;
                            model.CashCouponBn     = cashNo;
                            model.ShopId           = coupon.ShopId;
                            //设置订单归属用户
                            model.Ct_BelongId = coupon.UserId;
                            model.UserId      = coupon.BelongOneUserId;
                            cashUserId        = coupon.UserId;
                        }
                        else
                        {
                            apiCode = ApiStatusCode.优惠券不存在;
                            return(false);
                        }
                    }
                }
                //如果没有优惠
                if (cashUserId <= 0)
                {
                    //根据手机号或地址,查找客户
                    CustomerModel customer = cid > 0 ? CustomerLogic.getCustomerModel(cid) : CustomerLogic.getCustomerModel(mobile, address);
                    if (customer != null)
                    {
                        //设置订单归属用户
                        model.Ct_BelongId = customer.BelongOne;
                        model.UserId      = customer.BelongTwo;
                        model.ShopId      = customer.ShopId;
                        cashUserId        = customer.BelongOne;
                    }
                }
                TempBeansRecordsModel model1 = null;
                BeansRecordsModel     model2 = null;
                if (cashUserId > 0)
                {
                    using (var dal = FactoryDispatcher.UserFactory())
                    {
                        var user = dal.GetUserModel(cashUserId);
                        if (user.UserIdentity == 0)
                        {
                            model.UserId      = user.BelongOne;
                            model.Ct_BelongId = user.UserId;


                            var shopData = ShopLogic.GetShopModel(model.ShopId);
                            RewardsSettingModel rewardSettingModel = null;
                            //判断当前客户是否所属分店
                            if (shopData != null && shopData.ShopType == 2)
                            {
                                rewardSettingModel = UserLogic.GetRewardModel(model.ShopId);
                            }

                            if (rewardSettingModel != null && rewardSettingModel.OrderReward > 0)
                            {
                                //订单成交需付盟豆
                                model.MengBeans = rewardSettingModel.OrderReward;
                                //插入盟友订单成交临时奖励
                                model1            = new TempBeansRecordsModel();
                                model1.Amount     = rewardSettingModel.OrderReward;
                                model1.UserId     = cashUserId;
                                model1.LogType    = 0;
                                model1.Income     = 1;
                                model1.CreateTime = DateTime.Now;
                                model1.Status     = 0;
                                model1.Remark     = "下单";
                            }
                        }
                        else
                        {
                            model.UserId      = user.UserId;
                            model.Ct_BelongId = user.UserId;
                        }

                        //获取积分奖励配置
                        ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                        //添加盟主创建订单,奖励积分
                        if (scoreCfg.CreateOrderScore > 0 && dal.addUserIntegral(userId, scoreCfg.CreateOrderScore) > 0)
                        {
                            model2            = new BeansRecordsModel();
                            model2.Amount     = scoreCfg.CreateOrderScore;
                            model2.UserId     = userId;
                            model2.LogType    = 1;
                            model2.Income     = 1;
                            model2.Remark     = "创建订单奖励";
                            model2.OrderId    = "";
                            model2.CreateTime = DateTime.Now;
                        }
                    }
                }
                else
                {
                    using (var dal = FactoryDispatcher.UserFactory())
                    {
                        var user = dal.GetUserModel(userId);
                        model.UserId      = userId;
                        model.Ct_BelongId = userId;
                        model.ShopId      = user.ShopId;
                    }
                }
                bool flag = false;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (var dal = FactoryDispatcher.OrderFactory())
                    {
                        model.BelongOneShopId = ShopLogic.GetBelongShopId(model.ShopId);
                        if (model.BelongOneShopId == 0)
                        {
                            model.BelongOneShopId = model.ShopId;
                        }
                        flag = dal.Add(model);
                    }
                    if (flag)
                    {
                        //

                        //根据手机号或地址,查找客户,修改客户状态为已生成订单
                        CustomerModel customer = cid > 0 ? CustomerLogic.getCustomerModel(cid) : CustomerLogic.getCustomerModel(mobile, address);
                        if (customer != null)
                        {
                            using (var dal = FactoryDispatcher.CustomerFactory())
                            {
                                dal.UpdateStatus(customer.ID, 4);
                            }
                        }
                        //添加
                        using (var dald = FactoryDispatcher.UserFactory())
                        {
                            if (model1 != null)
                            {
                                dald.AddTempBeansRecords(model1);
                            }

                            //添加日志
                            if (model2 != null)
                            {
                                dald.AddBeansRecords(model2);
                            }
                        }

                        //添加优惠券使用记录
                        using (var cpDal = FactoryDispatcher.CouponFactory())
                        {
                            if (coupon != null)
                            {
                                if (cpDal.UpdateUserCashCouponUseStatus(coupon.ID))
                                {
                                    //添加优惠券领取操作日志
                                    LogLogic.AddCouponLog(new LogBaseModel()
                                    {
                                        objId         = coupon.CouponId,
                                        UserId        = coupon.UserId,
                                        ShopId        = coupon.ShopId,
                                        OperationType = 2,//0创建 1领取 2使用
                                        Money         = coupon.Money
                                    });
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("saveOrder==>Message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR);
                apiCode = ApiStatusCode.SERVICEERROR;
                return(false);
            }
        }
Exemple #16
0
        static bool Prefix(ref ImmediateRankUIPanel __instance, ref RelativeScoreAndImmediateRankCounter ____relativeScoreAndImmediateRankCounter,
                           ref RankModel.Rank ____prevImmediateRank, ref float ____prevRelativeScore, ref TextMeshProUGUI ____rankText,
                           ref TextMeshProUGUI ____relativeScoreText)
        {
            if (!CountersController.settings.Enabled)
            {
                return(true);                                      //Dont use Score Counters decimal precision if the plugin is disabled
            }
            if (model == null)
            {
                model = CountersController.settings.scoreConfig;
            }
            RankModel.Rank rank = ____relativeScoreAndImmediateRankCounter.immediateRank;
            if (rank != ____prevImmediateRank)
            {
                ____rankText.text     = model.Mode != ICounterMode.BaseGame ? $"\n{RankModel.GetRankName(rank)}" : RankModel.GetRankName(rank);
                ____prevImmediateRank = rank;
            }
            if (model.CustomRankColors) //checks if custom rank colors is enabled
            {
                if (RankModel.GetRankName(rank) == "SS")
                {
                    ColorUtility.TryParseHtmlString(model.SSColor, out Color RankColor); //converts config hex color to unity RGBA value
                    ____rankText.color = RankColor;                                      //sets color of ranktext
                }
                if (RankModel.GetRankName(rank) == "S")
                {
                    ColorUtility.TryParseHtmlString(model.SColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
                if (RankModel.GetRankName(rank) == "A")
                {
                    ColorUtility.TryParseHtmlString(model.AColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
                if (RankModel.GetRankName(rank) == "B")
                {
                    ColorUtility.TryParseHtmlString(model.BColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
                if (RankModel.GetRankName(rank) == "C")
                {
                    ColorUtility.TryParseHtmlString(model.CColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
                if (RankModel.GetRankName(rank) == "D")
                {
                    ColorUtility.TryParseHtmlString(model.DColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
                if (RankModel.GetRankName(rank) == "E")
                {
                    ColorUtility.TryParseHtmlString(model.EColor, out Color RankColor);
                    ____rankText.color = RankColor;
                }
            }
            float score = ____relativeScoreAndImmediateRankCounter.relativeScore;

            if (Mathf.Abs(____prevRelativeScore - score) >= 0.001f)
            {
                float roundedScore = (float)Math.Round((decimal)score * 100, model.DecimalPrecision);
                ____relativeScoreText.text = $"{roundedScore.ToString($"F{model.DecimalPrecision}")}%";
            }
            return(false);
        }