Пример #1
0
        /// <summary>
        /// 愿望上下架
        /// </summary>
        /// <param name="wishNo"></param>
        /// <param name="isOnline"></param>
        /// <returns></returns>
        public async Task <int> ChangeStatus(string activityNo, string wishNo, int isOnline)
        {
            string strSql = $@"UPDATE t_wish_base
                SET is_online={ isOnline } WHERE activity_no=@activityNo AND wish_no=@wishNo AND is_online<> { isOnline };";

            return(await _jiakeRepository.SQLExecute(strSql, new { activityNo, wishNo }));
        }
Пример #2
0
        /*****************************************分隔符*************************************************/

        /// <summary>
        /// 获取会员信息
        /// 如果存在直接取回,如果不存在就创建
        /// </summary>
        /// <param name="openId"></param>
        /// <param name="seeionKey"></param>
        /// <returns></returns>
        public async Task <LoginMemberResponse> GetMemberByOpenIdAsync(string activityNo, string openId, string sessionKey)
        {
            //查询会员是否存在
            string strSql = $@"SELECT
	                                id AS memberId,
	                                gender,
                                CASE
		                                WHEN LENGTH( tel ) > 0 THEN
		                                1 ELSE 0
	                                END AS isBind,
	                                nick_name AS nickName,avatar_url avatarUrl
                                FROM
	                                t_member
                                WHERE
	                                openId = @openId and is_deleted=0;"    ;
            var    member = await _jiakeRepository.SQLQueryFirstOrDefaultAsync <LoginMemberResponse>(strSql, new { openId });

            //会员存在,返回信息
            if (member != null && member.memberId > 0)
            {
                strSql = $@"UPDATE t_member SET session_key=@sessionKey,updated_time = NOW( ) WHERE id={member.memberId};";
                await _jiakeRepository.SQLExecute(strSql, new { sessionKey });
            }
            else //会员不存在,创建会员
            {
                strSql          = $@"INSERT INTO t_member (activity_no,openId,session_key,is_deleted,created_time)
                            VALUES (@activityNo,@openId,@sessionKey,0,NOW());
                            SELECT @@IDENTITY;";
                member          = new LoginMemberResponse();
                member.memberId = await _jiakeRepository.SQLQueryFirstOrDefaultAsync <int>(strSql, new { activityNo, openId, sessionKey });
            }
            return(member);
        }
Пример #3
0
        public async Task Invoke()
        {
            string activityNo = CronJobParam.ActivityNo;

            var(startTime, endTime) = await _cronJobParam.GetActivity();

            if (startTime.AddDays(2).Date == DateTime.Now.Date) // 活动第三天上午十点
            {
                string strSql = $@"UPDATE t_merchant
                SET fake_wish_complated=fake_wish_complated+152 WHERE activity_no=@activityNo;";

                await _jiakeRepository.SQLExecute(strSql, new { activityNo });
            }
        }
Пример #4
0
        public async Task Invoke()
        {
            string activityNo = CronJobParam.ActivityNo;

            var(startTime, endTime) = await _cronJobParam.GetActivity();

            if (endTime.Date == DateTime.Now.Date) // 活动结束
            {
                string strSql = $@"UPDATE t_make_wish
                SET `status`=3,updated_time=NOW() WHERE activity_no = @activityNo AND `status`=0;";
                await _jiakeRepository.SQLExecute(strSql, new { activityNo });
            }

            if (startTime.Date == DateTime.Now.Date)
            {
                // 活动开始,关注公众号全部用户发消息
                await _cronJobParam.AllSendTemplateMessage();
            }
        }
        // 2分钟
        public async Task Invoke()
        {
            #region 批量

            // 获取开始活动的ids
            // string acSql = $@"SELECT id,start_time FROM t_activity WHERE NOW() BETWEEN start_time AND end_time;";
            // var datas = (await _jiakeRepository.SQLQueryAsync<(int, DateTime)>(acSql)).ToList();

            // // 当前时间
            // var now = DateTime.Now;
            // foreach (var item in datas)
            // {
            //     var start_date = item.Item2;
            //     var fakeUp = GetFakeByStartDatetime(start_date, now);
            // }

            #endregion 批量

            // 活动编号
            // string acSql = $@"SELECT start_time FROM t_activity WHERE NOW() BETWEEN start_time AND end_time AND activity_no = @activity_no;";
            // var start_date = await _jiakeRepository.SQLQueryFirstOrDefaultAsync<DateTime>(acSql, new { activity_no });

            var(start_date, end_date) = await _cronJobParam.GetActivity();

            var now         = DateTime.Now;
            var activity_no = CronJobParam.ActivityNo;

            if (now >= start_date && now <= end_date)
            {
                // 计算天数获得应累加的值
                var fakeUp = GetFakeByStartDatetime(start_date, now);

                string sqlStr = $@"UPDATE t_activity SET fake_base = fake_base + @fakeUp WHERE activity_no = @activity_no;";
                var    result = await _jiakeRepository.SQLExecute(sqlStr, new { fakeUp, activity_no });

                if (result > 0)
                {
                    // log .. fake 成功
                }
            }
        }