public void TestSubmitQuestionUserAnswer()
        {
            using (var client = new ActivityClient())
            {
                var result = client.SubmitQuestionUserAnswer(new SubmitActivityQuestionUserAnswerRequest()
                {
                    AnswerDate          = DateTime.Now,
                    AnswerOptionContent = "测测",
                    AnswerOptionID      = -555,
                    AnswerText          = "否",
                    ObjectID            = 0,
                    QuestionID          = -44,
                    QuestionnaireID     = -6,
                    QuestionnaireName   = "测试问卷",
                    QuestionName        = "测试",
                    QuestionScore       = 0,
                    QuestionType        = 0,
                    UseIntegral         = 100,
                    UserId         = Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24"),
                    WinCouponCount = 10
                });


                Assert.IsNotNull(result.Result);
            }
        }
        public void TestSearchPrizeListByUserId()
        {
            using (var client = new ActivityClient())
            {
                var activity = client.GetWorldCup2018Activity();
                var coupon   = client.SearchPrizeList(new SearchPrizeListRequest()
                {
                    ActivityId = activity.Result.PKID,
                    ShowCanPay = false,
                    PageIndex  = 1,
                    PageSize   = 20,
                    UserId     = Guid.Parse("A3136282-251E-462A-AF0C-627843F5C649")
                });

                var coupon1 = client.SearchPrizeList(new SearchPrizeListRequest()
                {
                    ActivityId = activity.Result.PKID,
                    ShowCanPay = true,
                    PageIndex  = 1,
                    PageSize   = 20,
                    UserId     = Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24")
                });
                Assert.IsNotNull(coupon.Result);
            }
        }
        public void TestInsertActivityUserConpon()
        {
            using (var client = new ActivityClient())
            {
                var activity   = client.GetWorldCup2018Activity();
                var couponName = "单元测试";

                //client.ActivityCouponUpsert(Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24"), activity.Result.PKID, 1);

                client.ModifyActivityCoupon(Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24"), activity.Result.PKID, -101, couponName);

                client.ModifyActivityCoupon(Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24"), activity.Result.PKID, 1, couponName, DateTime.Parse("2017-01-01"));


                client.ModifyActivityCoupon(Guid.NewGuid(), activity.Result.PKID, 1, couponName);


                var i = 1;
                while (i <= 1000000)
                {
                    var guid = Guid.Parse("00000000-0000-0000-0000-00000" + i.ToString().PadLeft(7, '0'));
                    client.ModifyActivityCoupon(guid, activity.Result.PKID, i, couponName);
                    i++;
                }

                Assert.IsNotNull(true);
            }
        }
Beispiel #4
0
        public async Task <ActionResult> ApplyActivityPage(Guid activityId)
        {
            if (activityId == Guid.Empty)
            {
                return(Content("活动不存在"));
            }
            //判断当前活动有没有过期
            using (var client = new ActivityClient())
            {
                var result = await client.GetActivityModelByActivityIdAsync(activityId);

                if (result != null)
                {
                    if (result.Success && result.Result.EndTime < DateTime.Now.Date)
                    {
                        return(Content("该活动已过期"));
                    }
                    //判断当前活动审核通过人数是否已达上限
                    if (!await CheckApplyUserCountAsync(activityId, result.Result.Quota))
                    {
                        return(Content("活动报名人数已满"));
                    }
                }
                else
                {
                    return(Content("活动不存在"));
                }
            }
            ViewBag.ActivityId = activityId;
            return(View());
        }
Beispiel #5
0
        public async Task <JsonResult> GetActivityModels(int pageIndex = 1, int pageSize = 10)
        {
            using (var client = new ActivityClient())
            {
                var result = await client.GetActivityModelsPagedAsync(pageIndex, pageSize);

                if (result.Success)
                {
                    foreach (var activity in result.Result.Item1)
                    {
                        var applyUserCountResult =
                            await client.GetActivityApplyUserCountByActivityIdAsync(activity.ActivityId);

                        var auditPassUserCount =
                            await client.GetActivityApplyUserPassCountByActivityIdAsync(activity.ActivityId);

                        activity.ApplyUserCount     = applyUserCountResult.Success ? applyUserCountResult.Result : 0;
                        activity.AuditPassUserCount = auditPassUserCount.Success ? auditPassUserCount.Result : 0;
                    }
                    return(AjaxHelper.MvcJsonResult(HttpStatusCode.OK, "成功", result.Result));
                }
                else
                {
                    return(AjaxHelper.MvcJsonResult(HttpStatusCode.BadGateway, "服务器内部错误"));
                }
            }
        }
        private async Task <bool> CheckApplyUserCountAsync(Guid activityId)
        {
            //判断当前活动审核通过人数是否已达上限
            using (var activityClient = new ActivityClient())
            {
                //检查活动审核通过人数是否已满
                var applyUserPassCountResult =
                    await activityClient.GetActivityApplyUserPassCountByActivityIdAsync(activityId);

                var activityModelResult =
                    await activityClient.GetActivityModelByActivityIdAsync(activityId);

                if (applyUserPassCountResult.Success && activityModelResult.Success)
                {
                    if (applyUserPassCountResult.Result >= activityModelResult.Result.Quota)
                    {
                        return(false);
                    }
                }
                else
                {
                    Logger.Error($"审核通过人数查询失败。Message:{(applyUserPassCountResult.Success ? applyUserPassCountResult.Exception : activityModelResult.Exception)}");
                    return(false);
                }
            }
            return(true);
        }
Beispiel #7
0
        private void Run()
        {
            using (var acitivtyClient = new ActivityClient())
            {
                #region 世界杯活动清算

                //获取世界杯活动
                var activity = acitivtyClient.GetWorldCup2018Activity();

                if (activity.Success && activity.Result != null)
                {
                    //获取今天发布'结果'的题目  列表
                    var questions = DalActivity.SearchTodayReleaseQuestionAnswerList(activity.Result.QuestionnaireID)?.ToList();

                    if (questions != null)
                    {
                        if (questions.Count > 0)
                        {
                            //刷新缓存
                            RefreshCache(activity?.Result?.PKID ?? 0);
                        }

                        //循环问题
                        questions.ForEach(question =>
                        {
                            UserAnswerClear(question, activity.Result.PKID);
                        });
                    }
                }

                #endregion
            }
        }
Beispiel #8
0
 public void RecordActivityTypeLog(Guid activityId, DateTime startTime, DateTime endTime)
 {
     try
     {
         ActivityTypeRequest request = new ActivityTypeRequest()
         {
             ActivityId    = activityId,
             Type          = 5,
             Status        = 1,
             StartDateTime = startTime,
             EndDateTime   = endTime
         };
         using (var client = new ActivityClient())
         {
             var getResult = client.RecordActivityTypeLog(request);
             if (!getResult.Success && getResult != null)
             {
                 throw getResult.Exception;
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }
        /// <summary>
        /// 管理员注册
        /// </summary>
        /// <returns></returns>
        public Reseponse <bool> ManagerRegister(T_ActivityManagerUserInfo_xhrRequest model)
        {
            var result = new Reseponse <bool>();

            try
            {
                using (var client = new ActivityClient())
                {
                    var request = new Tuhu.Service.Activity.Models.T_ActivityManagerUserInfo_xhrModel()
                    {
                        Name      = model.Name,
                        PassWords = model.PassWords
                    };
                    var addresult = client.ManagerRegisterAsync(request);
                    result.status  = addresult.Result.Success ? 1 : 0;
                    result.Message = addresult.Result.ErrorMessage;
                    result.data    = addresult.Result.Success;
                }
            }
            catch (Exception e)
            {
                Logger.Error($"ManagerLogin -> {JsonConvert.SerializeObject(model)}", e);
                throw;
            }
            return(result);
        }
        /// <summary>
        /// 获取所有活动地区
        /// </summary>
        /// <returns></returns>
        public Reseponse <List <T_ArearModel> > GetAllAreaAsync()
        {
            var result = new Reseponse <List <T_ArearModel> >();

            try
            {
                using (var client = new ActivityClient())
                {
                    var model = client.GetAllAreaAsync().Result;
                    result.status  = model.Success ? 1 : 0;
                    result.Message = model.ErrorMessage;
                    result.data    = new List <T_ArearModel>();
                    if (model.Success && model.Result != null)
                    {
                        foreach (var item in model.Result)
                        {
                            result.data.Add(new T_ArearModel()
                            {
                                AreaId    = item.AreaId,
                                ArearName = item.ArearName
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error($"GetAllAreaAsync", e);
                throw;
            }
            return(result);
        }
 public void TestAddStarRatingStore()
 {
     using (var client = new ActivityClient())
     {
         var model = new AddStarRatingStoreRequest()
         {
             Phone                 = "1608938839",
             UserName              = "******",
             StoreName             = "美容店",
             Duty                  = "店长",
             ProvinceID            = 4,
             CityID                = 4,
             DistrictID            = 5,
             ProvinceName          = "上海",
             CityName              = "上海",
             DistrictName          = "李子园",
             StoreAddress          = "荣和",
             StoreArea             = 222.34M,
             StoreNum              = 4,
             WorkPositionNum       = 4,
             MaintainQualification = "二类",
             Storefront            = "美容",
             //StorefrontDesc="",
             StoreLocation = "小区里",
             IsAgree       = true
         };
         var result = client.AddStarRatingStore(model);
         Assert.IsNotNull(result.Result);
     }
 }
        public void TestSearchQuestionAnswerHistoryByUserId()
        {
            using (var client = new ActivityClient())
            {
                var activity = client.GetWorldCup2018Activity();
                var result   =
                    client.SearchQuestionAnswerHistoryByUserId(new SearchQuestionAnswerHistoryRequest()
                {
                    ActivityId = activity.Result.PKID,
                    PageIndex  = 1,
                    PageSize   = 20,
                    UserId     = Guid.Parse("A3136282-251E-462A-AF0C-627843F5C649")
                });


                result =
                    client.SearchQuestionAnswerHistoryByUserId(new SearchQuestionAnswerHistoryRequest()
                {
                    ActivityId = activity.Result.PKID,
                    PageIndex  = 1,
                    PageSize   = 20,
                    ShowFlag   = 1,
                    UserId     = Guid.Parse("A3136282-251E-462A-AF0C-627843F5C649")
                });
                Assert.IsNotNull(result.Result);
            }
        }
Beispiel #13
0
        public async Task <IActionResult> Refresh()
        {
            var user = await _userManager.GetUserAsync(User);

            var token = await _userManager.GetAccessToken(user, "Strava", _clientKeys["ClientId"], _clientKeys["ClientSecret"]);

            var client             = new ActivityClient(token);
            var latestActivityDate = DateTimeExtensions.FromUnixTime(0);
            var latestActivity     = _context.StravaActivities.OrderByDescending(x => x.StartDateTime).FirstOrDefault();

            if (latestActivity != null)
            {
                latestActivityDate = latestActivity.StartDateTime;
            }
            var activities = await client.GetAsync(null, latestActivityDate, null, null, false);

            //var staticMapApiKey = _configuration.GetSection("ApiKeys")["GoogleStaticMaps"];

            var dbActivities = _mapper.Map <ICollection <MyActiveLife.Apis.Strava.Entities.Activity>, List <StravaActivity> >(activities);
            var source       = _context.Sources.SingleOrDefault(x => x.SourceName == "Strava");

            dbActivities.ForEach(x =>
            {
                x.Source = source;
                x.UserId = new Guid(user.Id);
            });
            await _context.AddRangeAsync(dbActivities);

            var numberOfRecords = await _context.SaveChangesAsync();

            return(View(numberOfRecords));
        }
        public void TestActivityShare()
        {
            using (var client = new ActivityClient())
            {
                var activity = client.GetWorldCup2018Activity();
                var result   = client.ActivityShare(new ActivityShareDetailRequest()
                {
                    ActivityId     = activity.Result.PKID,
                    UserId         = Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24"),
                    ShareName      = "2018世界杯-分享送积分",
                    IntegralRuleID = activity.Result.ShareIntegralRuleID
                });


                var result1 = client.ActivityShare(new ActivityShareDetailRequest()
                {
                    ActivityId     = activity.Result.PKID,
                    UserId         = Guid.Parse("a3136282-251e-462a-af0c-627843f5c649"),
                    ShareName      = "2018世界杯-分享送积分",
                    IntegralRuleID = activity.Result.ShareIntegralRuleID
                });

                var result2 = client.ActivityShare(new ActivityShareDetailRequest()
                {
                    ActivityId     = activity.Result.PKID,
                    UserId         = Guid.Parse("5171B31F-B541-45B9-B9D9-7DC2DBA597ED"),
                    ShareName      = "2018世界杯-分享送积分",
                    IntegralRuleID = activity.Result.ShareIntegralRuleID
                });
                Assert.IsNotNull(result.Result);
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            _logger.Info("开始自动更新用户报名状态...");

            var watcher = new Stopwatch();

            watcher.Start();

            try
            {
                using (var client = new ActivityClient())
                {
                    client.UpdateUserRegistrationStatus(
                        "上海市闵行区",
                        RegistrationStatus.Passed);
                }
            }
            catch (Exception ex)
            {
                _logger.Warn("更新用户报名状态出现异常", ex);
            }

            watcher.Stop();

            _logger.Info($"报名状态更新完成,用时{watcher.ElapsedMilliseconds}毫秒。");
        }
        public void TestSubmitQuestionAnswer()
        {
            using (var client = new ActivityClient())
            {
                var activity = client.GetWorldCup2018Activity();

                //积分不足
                var result = client.SubmitQuestionAnswer(new SubmitQuestionAnswerRequest()
                {
                    ActivityId     = activity.Result.PKID,
                    IntegralRuleID = activity.Result.UserSelectionIntegralRuleID,
                    OptionId       = 212,
                    UserId         = Guid.Parse("00000000-0000-0000-0000-000000000001")
                });
                Assert.IsFalse(result.Success);

                //积分充足
                result = client.SubmitQuestionAnswer(new SubmitQuestionAnswerRequest()
                {
                    ActivityId     = activity.Result.PKID,
                    IntegralRuleID = activity.Result.UserSelectionIntegralRuleID,
                    OptionId       = 588,
                    UserId         = Guid.Parse("A5E65A7A-0CEF-4FC3-B364-291182034B24")
                });
                Assert.IsTrue(result.Success);


                //问题时间
            }
        }
 public void SelectCarTagCouponConfigsAsync()
 {
     using (var client = new ActivityClient())
     {
         var result = client.SelectCarTagCouponConfigs();
         Assert.IsNotNull(result.Result);
     }
 }
 public void TestGetActivityByActivityTypeId()
 {
     using (var client = new ActivityClient())
     {
         var result = client.GetActivityInfoByType(1);
         Assert.IsNotNull(result.Result);
     }
 }
 public void TestGetWorldCup2018Activity()
 {
     using (var client = new ActivityClient())
     {
         var result = client.GetWorldCup2018Activity();
         Assert.IsNotNull(result.Result);
     }
 }
 public void SelectRebateApplyByOpenId()
 {
     using (var client = new ActivityClient())
     {
         var result = client.SelectRebateApplyByOpenId("o7XCEtz2mIgNRAVmpaoHW8YJF2H4");
         Assert.IsNotNull(result.Result);
     }
 }
 public void SelectRebateApplyPageConfig()
 {
     using (var client = new ActivityClient())
     {
         var result = client.SelectRebateApplyPageConfig();
         Assert.IsNotNull(result.Result);
     }
 }
 public void UpdateBaoYangPurchaseCount()
 {
     using (var client = new ActivityClient())
     {
         var result = client.UpdateBaoYangPurchaseCount(Guid.Parse("b7b8fe14-c887-40b5-bd72-673bcaf56786"));
         Assert.IsTrue(result.Success);
     }
 }
 public void BindVipCardAsync()
 {
     using (var client = new ActivityClient())
     {
         var result = client.BindVipCard(778899);
         Assert.IsNotNull(result.Result);
     }
 }
 public void GetVipCardSaleConfigDetailsAsync()
 {
     using (var client = new ActivityClient())
     {
         var result = client.GetVipCardSaleConfigDetails("f32f72a0-b685-4a0a-b828-be3cf3be94bb");
         Assert.IsNotNull(result.Result);
     }
 }
 public void SelectTireActivityByActivityId()
 {
     using (var client = new ActivityClient())
     {
         var result = client.SelectTireActivityByActivityId(new Guid("4E8D5BC6-0658-49C8-B5AC-0834FE3CB6E8"));
         Assert.IsTrue(result.Success);
     }
 }
 public void GetActivityPageWhiteListByUserIdAsync()
 {
     using (var client = new ActivityClient())
     {
         var result = client.GetActivityPageWhiteListByUserId(new Guid("21FA116E-5AAF-4DD8-9EE0-C2D93CB026C7"));
         Assert.IsNotNull(result.Result);
     }
 }
 public void UpdateActivityPidsCache()
 {
     using (var client = new ActivityClient())
     {
         var result = client.UpdateActivityPidsCache(new Guid("4E8D5BC6-0658-49C8-B5AC-0834FE3CB6E8"));
         Assert.IsTrue(result.Success);
     }
 }
 public void ModifyVipCardRecordByOrderIdAsync()
 {
     using (var client = new ActivityClient())
     {
         var result = client.ModifyVipCardRecordByOrderId(1671266);
         Assert.IsNotNull(result.Result);
     }
 }
 public void SelectTireActivityPids()
 {
     using (var client = new ActivityClient())
     {
         var result = client.SelectTireActivityPids(new Guid("66AB4218-6EBD-4D54-8CC5-0F52C55CF302"));
         Assert.IsTrue(result.Success);
     }
 }
 public void GetFixedPriceActivityRound()
 {
     using (var client = new ActivityClient())
     {
         var result = client.GetFixedPriceActivityRound(Guid.Parse("b7b8fe14-c887-40b5-bd72-673bcaf56786"));
         Assert.IsTrue(result.Success);
     }
 }