Exemplo n.º 1
0
        public JsonResult EditStore(Account account, DishStore store, [System.Web.Http.FromBody] EditStore edit)
        {
            if (DishStoreBLL.SingleModel.CheckExistLoginName(store.id, store.aid, edit.Login))
            {
                //请输入门店管理员账号
                return(ApiModel(message: "存在同名的管理者账号,请修改!"));
            }

            store.updateTime      = DateTime.Now;
            store.dish_name       = edit.Name;
            store.dish_logo       = edit.Logo;
            store.dish_begin_time = edit.Begin.Value;
            store.dish_end_time   = edit.Expire.Value;
            store.login_username  = edit.Login;
            string updateColumns = "dish_name,dish_logo,dish_begin_time,dish_end_time,login_username,updateTime";

            if (!string.IsNullOrEmpty(edit.Password))
            {
                updateColumns       += ",login_userpass";
                store.login_userpass = DESEncryptTools.GetMd5Base32(edit.Password);
            }
            bool success = DishStoreBLL.SingleModel.Update(store, updateColumns);

            return(ApiModel(isok: success, message: success ? "更新成功" : "更新失败"));
        }
Exemplo n.º 2
0
        public JsonResult AddStore(Account account, [System.Web.Http.FromBody] EditStore edit, int?aId)
        {
            if (!aId.HasValue)
            {
                return(ApiModel(message: "参数不能为空_aId"));
            }
            if (string.IsNullOrEmpty(edit.Password))
            {
                return(ApiModel(message: "密码不能为空"));
            }

            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(aId.Value, account.Id.ToString());

            int storeCount = DishStoreBLL.SingleModel.GetCount($"aid={app.Id} and state<>-1");

            if (storeCount >= app.SCount)
            {
                return(ApiModel(message: $"门店数量已达到上限,您最多只能创建{app.SCount}个门店"));
            }

            DishStore store = new DishStore
            {
                updateTime      = DateTime.Now,
                dish_name       = edit.Name,
                dish_logo       = edit.Logo,
                dish_begin_time = edit.Begin.Value,
                dish_end_time   = edit.Expire.Value,
                login_username  = edit.Login,
                //如果只能创建一个门店,默认设置为主店
                ismain         = app.SCount <= 1 && storeCount == 0 ? 1 : 0,
                login_userpass = DESEncryptTools.GetMd5Base32(edit.Password),
                aid            = app.Id,
            };
            int  newId   = 0;
            bool success = int.TryParse(DishStoreBLL.SingleModel.Add(store)?.ToString(), out newId) && newId > 0;

            return(ApiModel(isok: success, message: success ? "新增成功" : "新增失败"));
        }