Ejemplo n.º 1
0
 public void Update(
     string id,
     string userName,
     string loginName,
     string password,
     string connString,
     string ket,
     string description)
 {
     using (O2OContext db = new O2OContext())
     {
         BaseService <UserEntity> baseService = new BaseService <UserEntity>(db);
         UserEntity entity = baseService.FirstOrDefault(a => a.Id == id) ?? throw new ArgumentNullException("ÉÌ»§²»´æÔÚ");
         entity.Id        = id;
         entity.UserName  = userName;
         entity.LoginName = loginName;
         if (!string.IsNullOrWhiteSpace(password))
         {
             entity.PasswordHash = ToolsCommon.MD5Encrypt(password + entity.PasswordSalt);
         }
         if (!string.IsNullOrWhiteSpace(connString))
         {
             entity.ConnString = ToolsCommon.ToBase64(connString);
         }
         entity.Ket         = ket;
         entity.Description = description;
         baseService.Update(entity);
     }
 }
Ejemplo n.º 2
0
        public async Task SetAsync(string userId, string shopNo, int mtState, int eleState)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <ShopConfigEntity>(context);

                var entity = await service.Entities.FirstOrDefaultAsync(a => a.UserId == userId && a.ShopNo == shopNo);

                if (entity != null)
                {
                    entity.MtAutoConfirm  = mtState;
                    entity.EleAutoConfirm = eleState;

                    service.Update(entity);
                }
                else
                {
                    var shopConfig = new ShopConfigEntity()
                    {
                        UserId         = userId,
                        ShopNo         = shopNo,
                        MtAutoConfirm  = mtState,
                        EleAutoConfirm = eleState
                    };
                    service.Add(shopConfig);
                }
            }
        }
Ejemplo n.º 3
0
        public int[] GetMissOrder(string userId, DateTime dateTime, string shopNo, int takeType)
        {
            Expression <Func <OrderEntity, bool> > expression = a => a.UserId.Equals(userId) && SqlFunctions.DateDiff("d", dateTime, a.OptTime) == 0 && a.ShopNo.Equals(shopNo) && a.TakeType.Equals(takeType);

            if (takeType == 1)
            {
                expression = a => a.UserId.Equals(userId) && (SqlFunctions.DateDiff("d", dateTime, a.OptTime) == (int?)0 && SqlFunctions.DateDiff("d", a.DeliverTime, "1970-01-01") == 0 || SqlFunctions.DateDiff("d", dateTime, a.DeliverTime) == 0) && a.ShopNo.Equals(shopNo) && a.TakeType.Equals(takeType);
            }
            using (var db = new O2OContext())
            {
                var baseService = new BaseService <OrderEntity>(db);

                var data = db.Order.Where(expression).GroupBy(a => new
                {
                    ShopNo = a.ShopNo
                }).Select(g => new
                {
                    MaxDaySeq = g.Max(a => a.DaySeq),
                    Count     = g.Count()
                }).FirstOrDefault();
                var numArray = new int[0];
                if (data == null || data.MaxDaySeq == data.Count)
                {
                    return(numArray);
                }
                var arrayDaySeq = baseService.Where(expression).Select(a => a.DaySeq).ToArray();
                numArray = Enumerable.Range(1, data.MaxDaySeq).Where(a => !arrayDaySeq.Contains(a)).ToArray();
                return(numArray);
            }
        }
Ejemplo n.º 4
0
        public async Task <List <StockRuleShopProdDTO> > GetListShopProdAsync(string userId)
        {
            var rules = new List <StockRuleEntity>();

            using (var context = new O2OContext())
            {
                var service = new BaseService <StockRuleEntity>(context);

                rules = await service
                        .Where(x => x.UserId == userId)
                        .Include(x => x.StockRuleShops)
                        .Include(x => x.StockRuleProds)
                        .ToListAsync();
            }

            var shopProds = new List <StockRuleShopProdDTO>();

            foreach (var rule in rules)
            {
                foreach (var stockRuleShop in rule.StockRuleShops)
                {
                    shopProds.Add(new StockRuleShopProdDTO()
                    {
                        ShopNo         = stockRuleShop.ShopNo,
                        StockRuleProds = rule.StockRuleProds.Select(x => ToolsCommon.EntityToEntity(x, new StockRuleProdDTO()) as StockRuleProdDTO).ToList()
                    });
                }
            }

            return(shopProds);
        }
Ejemplo n.º 5
0
        public void Add(
            string id,
            string userName,
            string loginName,
            string password,
            string connString,
            string ket,
            string description)
        {
            UserEntity entity = new UserEntity()
            {
                Id           = id,
                UserName     = userName,
                LoginName    = loginName,
                PasswordSalt = ToolsCommon.CreateVerifyCode(5)
            };

            entity.PasswordHash = ToolsCommon.MD5Encrypt(password + entity.PasswordSalt);
            entity.ConnString   = ToolsCommon.ToBase64(connString);
            entity.Ket          = ket;
            entity.Description  = description;
            entity.CreateDate   = DateTime.Now;
            using (O2OContext db = new O2OContext())
                new BaseService <UserEntity>(db).Add(entity);
        }
Ejemplo n.º 6
0
        public void Add(
            string userId,
            string accountNo,
            string accountName,
            string waimaiAppId,
            string waimaiAppSecret,
            string tuangouAppKey,
            string tuangouAppSecret,
            string description)
        {
            var entity = new Mt_AccountEntity()
            {
                UserId           = userId,
                AccountNo        = accountNo,
                AccountName      = accountName,
                WaimaiAppId      = waimaiAppId,
                WaimaiAppSecret  = waimaiAppSecret,
                TuangouAppKey    = tuangouAppKey,
                TuangouAppSecret = tuangouAppSecret,
                Description      = description
            };

            using (var db = new O2OContext())
                new BaseService <Mt_AccountEntity>(db).Add(entity);
        }
Ejemplo n.º 7
0
 public void DeleteProdNoMapInfo(string userId, string prodNo, string prodName)
 {
     using (var o2Ocontext = new O2OContext())
     {
         var sql = "WITH t AS (SELECT b.* FROM T_Order a INNER JOIN T_OrderDtl b ON a.Id = b.OrderId WHERE a.UserId= '" + userId + "' AND b.ProdNo = '" + prodNo + "' AND b.ProdName = '" + prodName + "') DELETE T_OrderDtl WHERE Id IN (SELECT Id FROM t)";
         o2Ocontext.Database.ExecuteSqlCommand(sql);
     }
 }
Ejemplo n.º 8
0
 public Mt_AccountDTO GetAccount(string userId)
 {
     using (var db = new O2OContext())
     {
         UserEntity userEntity = new BaseService <UserEntity>(db).Entities.FirstOrDefault(a => a.Id == userId);
         return(userEntity != null?ToolsCommon.EntityToEntity(userEntity.Mt_Accounts.FirstOrDefault(), new Mt_AccountDTO()) as Mt_AccountDTO : (Mt_AccountDTO)null);
     }
 }
Ejemplo n.º 9
0
 public Mt_AccountDTO GetAccount(Guid id)
 {
     using (var db = new O2OContext())
     {
         var mtAccountEntity = new BaseService <Mt_AccountEntity>(db).FirstOrDefault(a => a.Id == id);
         return(mtAccountEntity == null ? null : ToolsCommon.EntityToEntity(mtAccountEntity, new Mt_AccountDTO()) as Mt_AccountDTO);
     }
 }
Ejemplo n.º 10
0
        public void Delete(string userId)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <PreProdEntity> service = new BaseService <PreProdEntity>(context);

                service.Delete(a => a.UserId == userId);
            }
        }
Ejemplo n.º 11
0
        public void Update(OrderEntity entity)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                service.Update(entity);
            }
        }
Ejemplo n.º 12
0
        public async Task DeleteShopAsync(Guid id)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <StockRuleShopEntity>(context);

                service.Delete(id);
            }
        }
Ejemplo n.º 13
0
        public OrderEntity Get(Guid id)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                return(service.FirstOrDefault(a => a.Id == id));
            }
        }
Ejemplo n.º 14
0
        public OrderEntity GetByOrderId(string orderId)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                var entity = service.Where(a => a.OrderId == orderId).Include(a => a.OrderDtls).FirstOrDefault();
                return(entity);
            }
        }
Ejemplo n.º 15
0
        public void Update(Ele_AccountDTO dto)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <Ele_AccountEntity>(context);

                var entity = ToolsCommon.EntityToEntity(dto, new Ele_AccountEntity()) as Ele_AccountEntity;

                service.Update(entity);
            }
        }
Ejemplo n.º 16
0
        public bool IsExist(string orderId)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                var count = service.Count(a => a.OrderId == orderId);

                return(count != 0);
            }
        }
Ejemplo n.º 17
0
        public UserDTO GetByLoginName(string loginName, string id = "")
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <UserEntity> service = new BaseService <UserEntity>(context);

                var entity = service.Entities.FirstOrDefault(a => a.LoginName == loginName && (id == "" || a.Id != id));

                return(ToolsCommon.EntityToEntity(entity, new UserDTO()) as UserDTO);
            }
        }
Ejemplo n.º 18
0
        public void Update(OrderEntity entity, Dictionary <string, object> dic)
        {
            ToolsCommon.SetValue(entity, dic);

            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                service.Update(entity);
            }
        }
Ejemplo n.º 19
0
 public void UpdateDtl(IEnumerable <OrderDtlEntity> entities)
 {
     using (var db = new O2OContext())
     {
         var baseService = new BaseService <OrderDtlEntity>(db);
         foreach (var entity in entities)
         {
             baseService.UpdateForce(entity);
         }
     }
 }
Ejemplo n.º 20
0
        public Ele_AccountDTO Get(Guid id)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <Ele_AccountEntity>(context);

                Ele_AccountEntity entity = service.GetById(id);

                return(ToolsCommon.EntityToEntity(entity, new Ele_AccountDTO()) as Ele_AccountDTO);
            }
        }
Ejemplo n.º 21
0
        public UserDTO Get(string id)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <UserEntity> service = new BaseService <UserEntity>(context);

                var entity = service.Entities.FirstOrDefault(a => a.Id == id);

                return(ToolsCommon.EntityToEntity(entity, new UserDTO()) as UserDTO);
            }
        }
Ejemplo n.º 22
0
        public void Add(List <PreProdDTO> list)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <PreProdEntity> service = new BaseService <PreProdEntity>(context);

                var entityList = list.Select(a => ToolsCommon.EntityToEntity(a, new PreProdEntity()) as PreProdEntity).ToList();

                service.AddRange(entityList);
            }
        }
Ejemplo n.º 23
0
        public async Task CreateShopAsync(StockRuleShopDTO input)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <StockRuleShopEntity>(context);

                var entity = ToolsCommon.EntityToEntity(input, new StockRuleShopEntity()) as StockRuleShopEntity;

                service.Add(entity);
            }
        }
Ejemplo n.º 24
0
        public void UpdateState(string orderId, int state)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);
                var entity  = service.Entities.FirstOrDefault(a => a.OrderId == orderId);
                entity.State = state;

                service.Update(entity);
            }
        }
Ejemplo n.º 25
0
        public void Update(Ele_ShopDTO dto)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context);

                var entity = ToolsCommon.EntityToEntity(dto, new Ele_ShopEntity()) as Ele_ShopEntity;

                service.Update(entity);
            }
        }
Ejemplo n.º 26
0
        public void Add(UserDTO dto)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <UserEntity> service = new BaseService <UserEntity>(context);

                var entity = ToolsCommon.EntityToEntity(dto, new UserEntity()) as UserEntity;

                service.Add(entity);
            }
        }
Ejemplo n.º 27
0
        public bool hasPreProd(string userId, string[] prodNos)
        {
            using (O2OContext context = new O2OContext())
            {
                BaseService <PreProdEntity> service = new BaseService <PreProdEntity>(context);

                var count = service.Where(a => a.UserId == userId && prodNos.Contains(a.ProdNo)).Count();

                return(count > 0 ? true : false);
            }
        }
Ejemplo n.º 28
0
        public async Task <StockRuleProdDTO> GetProdAsync(Guid stockRuleId, string prodNo)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <StockRuleProdEntity>(context);

                var entity = await service.Entities.FirstOrDefaultAsync(x => x.StockRuleId == stockRuleId && x.ProdNo == prodNo);

                return(ToolsCommon.EntityToEntity(entity, new StockRuleProdDTO()) as StockRuleProdDTO);
            }
        }
Ejemplo n.º 29
0
        public async Task <ShopConfigDTO> GetAsync(string userId, string shopNo)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <ShopConfigEntity>(context);

                var entity = await service.Entities.FirstOrDefaultAsync(a => a.UserId == userId && a.ShopNo == shopNo);

                return(entity is null ? new ShopConfigDTO() : ToolsCommon.EntityToEntity(entity, new ShopConfigDTO()) as ShopConfigDTO);
            }
        }
Ejemplo n.º 30
0
        public void SetBuy(string userId, int buyState)
        {
            using (var context = new O2OContext())
            {
                var service = new BaseService <OrderEntity>(context);

                var entity = service.FirstOrDefault(a => a.OrderId == userId);
                entity.BuyState = buyState;

                service.Update(entity);
            }
        }