예제 #1
0
        public async Task Invoke()
        {
            string activityNo = CronJobParam.ActivityNo;

            string strWhere = string.Empty;

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

            //活动结束,未选择商户的不发消息
            if (endTime < DateTime.Now)
            {
                strWhere = " AND mak.mch_no IS NOT NULL ";
            }

            string strSql     = $@"SELECT
                    mak.id makeWishId,
                    bas.wish_name wishName,
                    bas.wish_unit wishUnit,
                    mak.user_count userCount,
                    bas.rules rulesStr,
	                mem.openId,
	                mem.nick_name,
                    mak.mch_no
                FROM
	                t_make_wish mak
	                LEFT JOIN t_member mem ON mem.id = mak.member_id
                    LEFT JOIN t_wish_base bas ON bas.wish_no = mak.wish_no
                WHERE
                    mak.activity_no = @activityNo
	                AND mak.exchange_status = 0
	                AND mak.`status` IN ( 1, 4 )
                    {strWhere}
	                AND (
		                DATE(
			                DATE_ADD( mak.complated_time, INTERVAL 1 DAY )) = DATE(
		                NOW())
		                OR DATE(
			                DATE_ADD( mak.complated_time, INTERVAL 3 DAY )) = DATE(
		                NOW()));"        ;
            var    memberlist = await _jiakeRepository.SQLQueryAsync <NoExchangeMember>(strSql, new { activityNo });

            foreach (var mem in memberlist)
            {
                if (!string.IsNullOrEmpty(mem.wishUnit) && mem.wishUnit != "--")
                {
                    var r = mem.rules.Where(e => e.n == mem.userCount).FirstOrDefault()?.r;
                    if (r != null)
                    {
                        mem.wishName = string.Concat(mem.wishName, r, mem.wishUnit);
                    }
                }

                await _cronJobParam.NoExchangeSendTemplateMessage(mem.makeWishId, mem.wishName, mem.openId, mem.nickName, mem.mch_no);
            }
        }
예제 #2
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 });
            }
        }
예제 #3
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 成功
                }
            }
        }