public IActionResult AddchangeGoods(dynamic model)
        {
            try
            {
                var response = ResponseModelFactory.CreateInstance;

                using (_dbContext)
                {
                    var entity = new GoodsExchange();
                    entity.StoreExchangeUuid = Guid.NewGuid();
                    entity.ShopId            = model.ShopId;
                    entity.IsDelete          = "0";
                    entity.SystemUserUuid    = model.SystemUserUuid;
                    entity.ExchageTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    entity.DeduceScore       = model.DeduceScore;
                    //entity.GoodsId = model.GoodsId;

                    var temp = _dbContext.HomeAddress.FirstOrDefault(x => x.HomeAddressUuid == entity.SystemUserUuid);
                    temp.Score = temp.Score - double.Parse(entity.DeduceScore);
                    _dbContext.GoodsExchange.Add(entity);
                    _dbContext.SaveChanges();


                    response.SetSuccess("兑换成功");
                    return(Ok(response));
                }
            }
            catch (Exception es)
            {
                return(Ok(es.Message));
            }
        }
예제 #2
0
        public IActionResult EditHomeScore(dynamic model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            using (_dbContext)
            {
                Guid   guid         = model.homeAddressUuid;
                int    lastDecScore = model.lastDecScore;
                int    janScore     = model.janScore;
                int    febScore     = model.febScore;
                int    marScore     = model.marScore;
                int    aprScore     = model.aprScore;
                int    mayScore     = model.mayScore;
                int    junScore     = model.junScore;
                int    julScore     = model.julScore;
                int    augScore     = model.augScore;
                int    sepScore     = model.sepScore;
                int    octScore     = model.octScore;
                int    novScore     = model.novScore;
                int    decScore     = model.decScore;
                string jifen        = model.jifen;
                var    query        = _dbContext.HomeAddress.FirstOrDefault(x => x.HomeAddressUuid == guid);
                var    entity       = _dbContext.Village.FirstOrDefault(x => x.IsDelete == "0" && query.Address.Contains(x.Vname) || query.Ccmmunity == x.Vname);
                if (entity != null)
                {
                    query.LastDec = lastDecScore;
                    query.Jan     = janScore;
                    query.Feb     = febScore;
                    query.Mar     = marScore;
                    query.Apr     = aprScore;
                    query.May     = mayScore;
                    query.Jun     = junScore;
                    query.Jul     = julScore;
                    query.Aug     = augScore;
                    query.Sep     = sepScore;
                    query.Oct     = octScore;
                    query.Nov     = novScore;
                    query.Dec     = decScore;
                    var datescore = _dbContext.DateScore.FirstOrDefault(x => x.HomeAddressUuid == query.HomeAddressUuid && x.AddTime.Contains(DateTime.Now.ToString("yyyy")));
                    if (datescore != null)
                    {
                        datescore.Jan = janScore;
                        datescore.Feb = febScore;
                        datescore.Mar = marScore;
                        datescore.Apr = aprScore;
                        datescore.May = mayScore;
                        datescore.Jun = junScore;
                        datescore.Jul = julScore;
                        datescore.Aug = augScore;
                        datescore.Sep = sepScore;
                        datescore.Oct = octScore;
                        datescore.Nov = novScore;
                        datescore.Dec = decScore;
                    }
                    else
                    {
                        var entity1 = new DateScore();
                        entity1.DateScoreUuid   = Guid.NewGuid();
                        entity1.HomeAddressUuid = query.HomeAddressUuid;
                        entity1.Jan             = janScore;
                        entity1.Feb             = febScore;
                        entity1.Mar             = marScore;
                        entity1.Apr             = aprScore;
                        entity1.May             = mayScore;
                        entity1.Jun             = junScore;
                        entity1.Jul             = julScore;
                        entity1.Aug             = augScore;
                        entity1.Sep             = sepScore;
                        entity1.Oct             = octScore;
                        entity1.Nov             = novScore;
                        entity1.Dec             = decScore;
                        entity1.AddTime         = DateTime.Now.ToString("yyyy-MM-dd");
                        _dbContext.Add(entity1);
                    }
                    _dbContext.SaveChanges();
                    GoodsExchange gd = new GoodsExchange();
                    gd.StoreExchangeUuid = Guid.NewGuid();
                    gd.SystemUserUuid    = guid;
                    gd.ExchageTime       = DateTime.Now.ToString("yyyy-MM-dd");
                    gd.DeduceScore       = jifen;
                    gd.IsDelete          = "0";
                    _dbContext.Add(gd);
                    _dbContext.SaveChanges();
                }
                else
                {
                    response.SetFailed("该住户未归属社区");
                }
                return(Ok(response));
            }
        }