Пример #1
0
        public Switch(SwitchModel @switch, ExecutionEngine logic)
        {
            this.create = () =>
            {
                var selector = logic.Operators.CreateProperty(@switch.Key);

                var cases = @switch.Cases.Select(c =>
                                                 Expression.SwitchCase(logic.Operators.CreateFrom(c.Operator),
                                                                       c.When.SplitBy(',', ' ').Select(when => when.ToExpression(selector.Type))));

                Expression @default = @switch.Default.IfExists(d => logic.Operators.CreateFrom(d));

                if (@default == null)
                {
                    // generate a default case throwing an exception:
                    var exception = CreateException(selector.Expression);

                    @default = cases.Any()
                        ? Expression.Throw(exception, cases.First().Body.Type)
                        : Expression.Throw(exception);
                }

                var selectorExpression = selector.Expression;
                if (selector.Expression.Type.IsGenericType &&
                    selector.Expression.Type.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    var underlying = selector.Expression.Type.GetGenericArguments()[0];
                    selectorExpression = Expression.Convert(selectorExpression, underlying);
                }

                return(Expression.Switch(selectorExpression, @default, cases.ToArray()));
            };
        }
Пример #2
0
        /// <summary>
        /// 客户预订成功后将选定的时间点添加到已服务时间表
        /// </summary>
        /// <param name="store"></param>
        /// <param name="goodsCart"></param>
        public void AddSelServiceTime(FootBath store, EntGoodsCart goodsCart, SwitchModel switchModel = null)
        {
            ServiceTime serviceTimeModel = GetModel($"aid={store.appId} and storeid={store.Id} and tid={goodsCart.technicianId} and date='{goodsCart.reservationTime.ToShortDateString()}'");

            if (serviceTimeModel == null)
            {
                serviceTimeModel            = new ServiceTime();
                serviceTimeModel.aid        = store.appId;
                serviceTimeModel.storeId    = store.Id;
                serviceTimeModel.tid        = goodsCart.technicianId;
                serviceTimeModel.date       = Convert.ToDateTime(goodsCart.reservationTime.ToShortDateString());
                serviceTimeModel.time       = goodsCart.reservationTime.ToString("HH:mm");//SelTimeStr(goodsCart.reservationTime, goodsCart.goodsMsg.ServiceTime, switchModel.TimeInterval);
                serviceTimeModel.createTime = DateTime.Now;
                Add(serviceTimeModel);
            }
            else
            {
                serviceTimeModel.time      += "," + goodsCart.reservationTime.ToString("HH:mm"); //SelTimeStr(goodsCart.reservationTime, goodsCart.goodsMsg.ServiceTime, switchModel.TimeInterval);
                serviceTimeModel.date       = Convert.ToDateTime(goodsCart.reservationTime.ToShortDateString());
                serviceTimeModel.createTime = DateTime.Now;
                MySqlParameter[] arr    = null;
                string           strSql = BuildUpdateSql(serviceTimeModel, "time,createtime", out arr);
                Update(serviceTimeModel, "time,createtime,date");
            }
        }
Пример #3
0
    public void SetModels()
    {
        if (!modelSET)
        {
            if (swiMod == null)
            {
                swiMod = GetComponent <SwitchModel>();
            }

            swiMod.models     = new MeshFilter[11];
            swiMod.models[0]  = FindObjectOfType <AMONE>().GetComponent <MeshFilter>();
            swiMod.models[1]  = FindObjectOfType <AMTWO>().GetComponent <MeshFilter>();
            swiMod.models[2]  = FindObjectOfType <AMTHREE>().GetComponent <MeshFilter>();
            swiMod.models[3]  = FindObjectOfType <AMFOUR>().GetComponent <MeshFilter>();
            swiMod.models[4]  = FindObjectOfType <AMFIVE>().GetComponent <MeshFilter>();
            swiMod.models[5]  = FindObjectOfType <AMSIX>().GetComponent <MeshFilter>();
            swiMod.models[6]  = FindObjectOfType <AMSEVEN>().GetComponent <MeshFilter>();
            swiMod.models[7]  = FindObjectOfType <AMEIGHT>().GetComponent <MeshFilter>();
            swiMod.models[8]  = FindObjectOfType <AMNINE>().GetComponent <MeshFilter>();
            swiMod.models[9]  = FindObjectOfType <AMTEN>().GetComponent <MeshFilter>();
            swiMod.models[10] = FindObjectOfType <AMELEVEN>().GetComponent <MeshFilter>();

            modelSET = true;
        }
    }
Пример #4
0
        // GET: footbath_gift:足浴版小程序-送花管理
        #region 送花管理
        /// <summary>
        /// 送花配置界面
        /// </summary>
        /// <returns></returns>
        public ActionResult GiftSetting()
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            ViewBag.appId = appId;
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有权限!", code = "403"
                }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId);

            if (storeModel == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有数据!", code = "500"
                }));
            }


            ViewBag.GiftPrice = storeModel.ShowGiftPrice;
            SwitchModel switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);

            ViewBag.ShowPhotoByGift = switchModel.ShowPhotoByGift;

            List <EntGoods> giftPackages = EntGoodsBLL.SingleModel.GetGiftPackages(appId, (int)GoodsType.足浴版送花套餐);

            if (giftPackages == null || giftPackages.Count <= 0)
            {
                EntGoods giftPackage = new EntGoods()
                {
                    aid      = appId,
                    exttypes = ((int)GoodsType.足浴版送花套餐).ToString(),
                    stock    = 2,
                    name     = "看相册",
                    state    = 1,
                };
                giftPackage.id = Convert.ToInt32(EntGoodsBLL.SingleModel.Add(giftPackage));
                giftPackages   = new List <EntGoods>();
                giftPackages.Add(giftPackage);
            }
            return(View(giftPackages));
        }
Пример #5
0
 protected override void Start()
 {
     base.Start();
     indexLength = System.Enum.GetValues(typeof(gripModel)).Length - 1;
     currentGrip = (gripModel)curPos;
     swiMod      = GetComponent <SwitchModel>();
     SetModels();
 }
        public SwitchPropertiesWindow(Switch mswitch, DesignerItem item, Level level)
            : base()
        {
            InitializeComponent();
            item.PropertyWindow = this;
            DataContext = new SwitchModel(mswitch, item, level);

            foreach(Obstacle target in level.Obstacles.Where(o => o.Actions.Any(pair => pair.Key == mswitch.Guid)))
                mTriggers.Children.Add(new ActionControl(mTriggers, mswitch, level, target));

            UpdatePossibleActions();
        }
Пример #7
0
    public void SetModels()
    {
        if (!modelsSET)
        {
            if (swiMod == null)
            {
                swiMod = GetComponent <SwitchModel>();
            }

            swiMod.models    = new MeshFilter[4];
            swiMod.models[0] = FindObjectOfType <GMONE>().GetComponent <MeshFilter>();
            swiMod.models[1] = FindObjectOfType <GMTWO>().GetComponent <MeshFilter>();
            swiMod.models[2] = FindObjectOfType <GMTHREE>().GetComponent <MeshFilter>();
            swiMod.models[3] = FindObjectOfType <GMFOUR>().GetComponent <MeshFilter>();

            modelsSET = true;
        }
    }
Пример #8
0
        /// <summary>
        /// 保存支付方式
        /// </summary>
        /// <returns></returns>
        public ActionResult SavePayWay(SwitchModel paySetting)
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null" }));
            }
            if (paySetting == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙switch_null" }));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙relation_null" }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}");

            if (storeModel == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙model_null" }));
            }
            storeModel.switchModel              = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);
            storeModel.switchModel.Alipay       = paySetting.Alipay;
            storeModel.switchModel.BankCardPay  = paySetting.BankCardPay;
            storeModel.switchModel.CashPay      = paySetting.CashPay;
            storeModel.switchModel.OtherPay     = paySetting.OtherPay;
            storeModel.switchModel.SaveMoneyPay = paySetting.SaveMoneyPay;
            storeModel.switchModel.WeChatPay    = paySetting.WeChatPay;
            storeModel.SwitchConfig             = JsonConvert.SerializeObject(storeModel.switchModel);
            storeModel.UpdateDate = DateTime.Now;
            bool   isok = FootBathBLL.SingleModel.Update(storeModel, "switchconfig,updatedate");
            string msg  = isok ? "修改成功" : "修改失败";

            return(Json(new { isok = isok, msg = msg }));
        }
Пример #9
0
        /// <summary>
        /// 数字量开关协议码生成,以数据模型
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static byte[] GetSwitchBytes(SwitchModel model)
        {
            //协议头
            var buf = new byte[6]
            {
                0x01,
                0x05,
                0x00,
                (byte)model.Port,
                (byte)model.Status,
                0x00
            };
            var crc = CrcModbus.Get(buf);       //校验码
            //协议码拼装
            var code = new List <byte>();

            code.AddRange(buf);
            code.AddRange(crc);
            return(code.ToArray());
        }
Пример #10
0
        private void DisplayModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(DisplayModel.StreamInfoArray):
                updateStreamTypes();
                break;

            case nameof(DisplayModel.StreamName):
                WindowUtil.BeginInvoke(() => { SelectedStreamType = DisplayModel.StreamName == null ? DefaultStreamType : DisplayModel.StreamName; });
                break;

            case nameof(DisplayModel.VideoName):
                if (PTZControl.IsShowControl)
                {
                    PTZControl.UpdatePTZStatus();
                    TrackSource.LoadTrackSwap(VideoId);
                    SwitchModel.UpdateSwitchInfo();
                }
                break;
            }
        }
Пример #11
0
        /// <summary>
        /// 送花记录(视图)
        /// </summary>
        /// <returns></returns>
        public ActionResult GiftRecord()
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            ViewBag.appId = appId;
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有权限!", code = "403"
                }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId);

            if (storeModel == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "数据不存在!", code = "500"
                }));
            }
            SwitchModel switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);

            ViewBag.ShowPhotoByGift = switchModel.ShowPhotoByGift;
            return(View());
        }
Пример #12
0
        /// <summary>
        /// 开启|关闭 送花看相册功能
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveGiftConfig()
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙id_null" }));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙account_null" }));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙relation_null" }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId);

            if (storeModel == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙store_null" }));
            }
            int isOpen = Context.GetRequestInt("isOpen", -1);

            if (isOpen < 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙isOpen_null" }));
            }
            SwitchModel switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);

            switchModel.ShowPhotoByGift = isOpen > 0;
            storeModel.SwitchConfig     = JsonConvert.SerializeObject(switchModel);
            storeModel.UpdateDate       = DateTime.Now;
            bool isok = FootBathBLL.SingleModel.Update(storeModel, "switchconfig,updatedate");

            return(Json(new { isok = isok }));
        }
Пример #13
0
        private void SetupStubbedSwitch(bool isProRata = false)
        {
            var switchResource = new SwitchResource
            {
                Links = new List <Link>
                {
                    new Link
                    {
                        Rel = isProRata ? "/rels/domestic/contract-details" : "dummy-rel",
                        Uri = isProRata ? "contract-expiry-date-uri" : "dummy-uri"
                    },
                    new Link
                    {
                        Rel = "/rels/next",
                        Uri = "next-uri"
                    }
                }
            };

            var switchModel = new SwitchModel(switchResource);

            _modelLoader.Load <SwitchResource, SwitchModel>("switch-uri").Returns(switchModel);
        }
Пример #14
0
        /// <summary>
        /// 保存早中晚班值班时间
        /// </summary>
        /// <param name="switchModel"></param>
        /// <returns></returns>
        public ActionResult saveWorkTime(SwitchModel switchModel)
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null" }));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙relation_null" }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}");

            if (storeModel == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙store_null" }));
            }
            storeModel.switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);
            storeModel.switchModel.morningShift = switchModel.morningShift;
            storeModel.switchModel.noonShift    = switchModel.noonShift;
            storeModel.switchModel.eveningShift = switchModel.eveningShift;

            storeModel.SwitchConfig = JsonConvert.SerializeObject(storeModel.switchModel);
            storeModel.UpdateDate   = DateTime.Now;
            bool   isok = FootBathBLL.SingleModel.Update(storeModel, "SwitchConfig,UpdateDate");
            string msg  = isok ? "保存成功" : "保存失败";

            return(Json(new { isok = isok, msg = msg }));
        }
Пример #15
0
        /// <summary>
        /// 获取当前订单用户可以得到首单立减优惠的金额(单位:分)
        /// </summary>
        /// <param name="curOrderMoney"></param>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public int getFirstOrderDiscountMoney(int userId, int aId, int storeId, TmpType tmpType)
        {
            float discountMoneySum = 0f;               //总的优惠金额
            float newUserFirstOrderDiscountMoney = 0f; //新用户首单立减
            float userFirstOrderDiscountMoney    = 0f; //用户首单立减

            bool isNewUserFirstOrder = false;          //新下单用户为新用户首单
            bool isTodayFirstOrder   = false;          //用户每天下的首单为用户首单

            #region 获取 新用户首单立减,用户首单立减
            switch (tmpType)
            {
            case TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {aId} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    return(0);
                }

                newUserFirstOrderDiscountMoney = store_Food.funJoinModel.newUserFirstOrderDiscountMoney;
                userFirstOrderDiscountMoney    = store_Food.funJoinModel.userFirstOrderDiscountMoney;
                break;

            case TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {aId} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    return(0);
                }
                storeId = store_MultiStore.Id;

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }

                newUserFirstOrderDiscountMoney = switchModel.newUserFirstOrderDiscountMoney;
                userFirstOrderDiscountMoney    = switchModel.userFirstOrderDiscountMoney;
                break;

            default:
                return(0);
            }
            #endregion

            if (newUserFirstOrderDiscountMoney == 0f && userFirstOrderDiscountMoney == 0f)
            {
                return(0);
            }

            #region 查询 是否满足优惠条件
            switch (tmpType)
            {
            case TmpType.小程序餐饮模板:

                isNewUserFirstOrder = !FoodGoodsOrderBLL.SingleModel.Exists($" userId = {userId} and  storeId ={storeId} ");
                isTodayFirstOrder   = !FoodGoodsOrderBLL.SingleModel.Exists($" userId = {userId} and  storeId ={storeId} and CreateDate >= '{DateTime.Now.ToString("yyyy-MM-dd")}' ");
                break;

            case TmpType.小程序多门店模板:
                isNewUserFirstOrder = !EntGoodsOrderBLL.SingleModel.Exists($" userId = {userId} and aId = {aId} and  storeId ={storeId} ");
                isTodayFirstOrder   = !EntGoodsOrderBLL.SingleModel.Exists($" userId = {userId} and aId = {aId} and  storeId ={storeId} and CreateDate >= '{DateTime.Now.ToString("yyyy-MM-dd")}' ");
                break;

            default:
                return(0);
            }
            #endregion

            //二者不可累加,取最大值
            if (isNewUserFirstOrder && discountMoneySum < newUserFirstOrderDiscountMoney)
            {
                discountMoneySum = newUserFirstOrderDiscountMoney;
            }
            if (isTodayFirstOrder && discountMoneySum < userFirstOrderDiscountMoney)
            {
                discountMoneySum = userFirstOrderDiscountMoney;
            }

            return(Convert.ToInt32(discountMoneySum * 100));
        }
Пример #16
0
        /// <summary>
        /// 获取预订技师时间列表
        /// </summary>
        /// <param name="shopTime"></param>
        /// <param name="timeInterval"></param>
        /// <param name="dates"></param>
        /// <returns></returns>
        public object GetTimeTable(SwitchModel switchModel, int days, int appId, int storeId, int tid)
        {
            DateTime date         = DateTime.Now.AddDays(days);
            bool     isSingleWeek = IsSingleWeek(date);
            string   sqlwhere     = $"aid={appId} and state>=0 and tid={tid}";

            if (isSingleWeek)
            {
                sqlwhere += " and daytype=0";
            }
            else
            {
                sqlwhere += " and daytype=1";
            }
            //获取技师当天排班情况
            Rota rota = RotaBLL.SingleModel.GetModel(sqlwhere);

            if (rota == null)
            {
                return(null);
            }
            List <object> TimeTable   = new List <object>();
            string        worktimeStr = string.Empty;

            switch (Convert.ToInt32(date.DayOfWeek))
            {
            //周日
            case 0:
                if (!switchModel.Sunday)    //店铺周日没有营业
                {
                    return(null);
                }
                worktimeStr = rota.sunday;
                break;

            //周一
            case 1:
                if (!switchModel.Monday)    //店铺周一没有营业
                {
                    return(null);
                }
                worktimeStr = rota.monday;
                break;

            //周二
            case 2:
                if (!switchModel.Tuesday)    //店铺周二没有营业
                {
                    return(null);
                }
                worktimeStr = rota.tuesday;
                break;

            //周三
            case 3:
                if (!switchModel.Wensday)    //店铺周三没有营业
                {
                    return(null);
                }
                worktimeStr = rota.wensday;
                break;

            //周四
            case 4:
                if (!switchModel.Thursday)    //店铺周四没有营业
                {
                    return(null);
                }
                worktimeStr = rota.thursday;
                break;

            //周五
            case 5:
                if (!switchModel.Friday)    //店铺周五没有营业
                {
                    return(null);
                }
                worktimeStr = rota.friday;
                break;

            //周六
            case 6:
                if (!switchModel.Saturday)    //店铺周六没有营业
                {
                    return(null);
                }
                worktimeStr = rota.saturday;
                break;
            }
            WorkTimeState workState = RotaBLL.SingleModel.GetDayState(worktimeStr);
            List <string> timeList  = new List <string>();

            //早班
            if (workState.morning)
            {
                string   startTime = switchModel.morningShift.Split('-')[0];
                DateTime start     = Convert.ToDateTime(startTime);
                string   endTime   = switchModel.morningShift.Split('-')[1];
                DateTime end       = Convert.ToDateTime(endTime);
                while (DateTime.Compare(end, start) > 0)
                {
                    timeList.Add(start.ToString("HH:mm"));
                    start = start.AddMinutes(switchModel.TimeInterval);
                    //TimeTable.Add(new { time = start.ToString("HH:mm"), state = false });
                }
            }
            //中班
            if (workState.noon)
            {
                string   startTime = switchModel.noonShift.Split('-')[0];
                DateTime start     = Convert.ToDateTime(startTime);
                string   endTime   = switchModel.noonShift.Split('-')[1];
                DateTime end       = Convert.ToDateTime(endTime);
                while (DateTime.Compare(end, start) > 0)
                {
                    timeList.Add(start.ToString("HH:mm"));
                    start = start.AddMinutes(switchModel.TimeInterval);
                }
            }
            //晚班
            if (workState.evening)
            {
                string   startTime = switchModel.eveningShift.Split('-')[0];
                DateTime start     = Convert.ToDateTime(startTime);
                string   endTime   = switchModel.eveningShift.Split('-')[1];
                DateTime end       = Convert.ToDateTime(endTime);
                while (DateTime.Compare(end, start) > 0)
                {
                    timeList.Add(start.ToString("HH:mm"));
                    start = start.AddMinutes(switchModel.TimeInterval);
                }
            }
            //去除已被选定的服务时间
            ServiceTime dates = GetModel($"aid={appId} and storeid={storeId} and tid={tid} and date='{DateTime.Now.AddDays(days).ToShortDateString()}'");

            if (dates != null)
            {
                List <string> list = dates.time.Split(',').ToList();;
                timeList = timeList.Except(list).ToList();
            }
            foreach (var timestr in timeList)
            {
                DateTime time = Convert.ToDateTime(timestr);
                //如果是今天,要去掉今天已经过去的时间
                if (DateTime.Compare(time, DateTime.Now) > 0 || days > 0)
                {
                    var obj = new
                    {
                        time  = timestr,
                        state = false
                    };
                    TimeTable.Add(obj);
                }
            }
            return(TimeTable);
        }
Пример #17
0
        public ActionResult ModifyFirstOrderDiscountMoneySetting(int appId, int storeId = 0, float newUserFirstOrderDiscountMoney = 0.00f, float userFirstOrderDiscountMoney = 0.00f)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = "保存成功";

            if (newUserFirstOrderDiscountMoney < 0 || newUserFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "201";
                handingResult.Msg  = "新用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            if (userFirstOrderDiscountMoney < 0 || userFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "202";
                handingResult.Msg  = "用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                //修改设定
                switchModel.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;

                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
Пример #18
0
        public ActionResult ModifyMeetMoneySwitchState(int appId, int storeId = 0, bool discountRuleSwitch = false)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = discountRuleSwitch ? "已开启" : "已关闭";

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch = discountRuleSwitch;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch = discountRuleSwitch;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
Пример #19
0
        /// <summary>
        /// 将 CommonSetting 逆推更入数据库
        /// </summary>
        /// <param name="commonSetting"></param>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Return_Msg UpdateCommonSetting(CommonSetting commonSetting, int aId, int storeId = 0)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = false;

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(handingResult);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(handingResult);
            }

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                foodConfig.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;
                foodConfig.sortQueueSwitch = commonSetting.sortQueueSwitch;
                foodConfig.sortNo_next     = commonSetting.sortNo_next;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                handingResult.isok = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                switchModel.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                handingResult.isok            = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                handingResult.Msg             = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                store.funJoinModel.sortQueueSwitch = commonSetting.sortQueueSwitch;
                store.funJoinModel.sortNo_next     = commonSetting.sortNo_next;
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);

                store.UpdateDate   = DateTime.Now;
                handingResult.isok = StoreBLL.SingleModel.Update(store, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(handingResult);
            }
        }
Пример #20
0
        /// <summary>
        /// 根据传入aId及storeId去读取店铺资料配置,自动查出默认关联的店铺的配置
        /// </summary>
        /// <param name="aId"></param>
        /// <param name="storeId">店铺ID,可传0,传0默认查出关联的店铺</param>
        /// <param name="errorMsg"></param>
        /// <param name="CommonSetting">公共配置</param>
        /// <returns></returns>
        public static CommonSetting GetCommonSetting(int aId, ref int storeId, ref string errorMsg)
        {
            CommonSetting         setting     = new CommonSetting();
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                errorMsg = "未找到小程序授权资料";
                return(setting);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                errorMsg = "未找到小程序的模板";
                return(setting);
            }
            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_Food.Id;

                setting.discountRuleSwitch             = store_Food.funJoinModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = store_Food.funJoinModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = store_Food.funJoinModel.userFirstOrderDiscountMoney;
                setting.sortQueueSwitch = store_Food.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store_Food.funJoinModel.sortNo_next;
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_MultiStore.Id;

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                setting.discountRuleSwitch             = switchModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = switchModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = switchModel.userFirstOrderDiscountMoney;
                break;

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                setting.sortQueueSwitch = store.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store.funJoinModel.sortNo_next;
                break;

            default:
                errorMsg = "还未开通店铺";
                return(setting);
            }
            return(setting);
        }
Пример #21
0
 private void Select_model(object sender, RoutedEventArgs e)
 {
     SwitchModel.Select_model(sender, e, this);
 }
Пример #22
0
 private void SwitchModel_Event(object sender, RoutedEventArgs e)
 {
     SwitchModel.HandleEvent(sender, this);
 }
Пример #23
0
    void UpdateTheMachine()
    {
        TheMachine.weapon         = currWeapon.GetComponent <Weapon>();
        TheMachine.weapon.enabled = false;
        gunTransform = currWeapon.transform;
        statSlider.SetWeapon(GameObject.FindWithTag("Gun").GetComponent <Weapon>());
        foreach (Button btn in craftingCanvas.GetComponentsInChildren <Button>())
        {
            btn.onClick.RemoveAllListeners();
            if (btn.name.Contains("Grip"))
            {
                GameObject grip = GameObject.Find("Grip");
                Debug.Log(grip.name);
                SwitchModel gripSwitch = grip.GetComponent <SwitchModel>();
                if (btn.name.Contains("Next"))
                {
                    btn.onClick.AddListener(delegate { gripSwitch.SwapModelUp(); });
                    Debug.Log("Swap Up Function Added");
                }
                else
                {
                    btn.onClick.AddListener(delegate { gripSwitch.SwapModelDown(); });
                }
            }
            else if (btn.name.Contains("Barrel"))
            {
                GameObject  barrel       = GameObject.Find("Barrel");
                SwitchModel barrelSwitch = barrel.GetComponent <SwitchModel>();
                if (btn.name.Contains("Next"))
                {
                    btn.onClick.AddListener(delegate { barrelSwitch.SwapModelUp(); });
                }
                else
                {
                    btn.onClick.AddListener(delegate { barrelSwitch.SwapModelDown(); });
                }
            }
            else if (btn.name.Contains("Ammo"))
            {
                GameObject  ammo       = GameObject.Find("Ammo");
                SwitchModel ammoSwitch = ammo.GetComponent <SwitchModel>();
                if (ammoSwitch != null)
                {
                    if (btn.name.Contains("Next"))
                    {
                        btn.onClick.AddListener(() => { ammoSwitch.SwapModelUp(); });
                    }
                    else
                    {
                        btn.onClick.AddListener(() => { ammoSwitch.SwapModelDown(); });
                    }
                }
                else
                {
                    Debug.Log("Switcher Doesn't Exist.");
                }
            }
        }
        foreach (SwitchModel comp in currWeapon.GetComponentsInChildren <SwitchModel>())
        {
            GameObject component = comp.gameObject;
            switch (comp.GetComponentType())
            {
            case ComponentType.ammo:
                comp.SetCurrentIndex(currentAmmo);
                break;

            case ComponentType.grip:
                comp.SetCurrentIndex(currentGrip);
                break;

            case ComponentType.barrel:
                comp.SetCurrentIndex(currentBarrel);
                break;

            case ComponentType.none:
                break;

            default:
                break;
            }
        }

        currWeapon.GetComponent <GunModel>().RunStats();
        btnMan.UpdateRotators();
    }
Пример #24
0
        /// <summary>
        /// 数字量开关协议码生成
        /// </summary>
        /// <param name="port"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static byte[] GetSwitchBytes(uint port, bool status)
        {
            var model = new SwitchModel(port, status);

            return(GetSwitchBytes(model));
        }