package com.iamberry.wechat.handles.mq;

import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.auth0.jwt.internal.org.apache.commons.lang3.StringEscapeUtils;
import com.iamberry.app.config.ImberryConfig;
import com.iamberry.wechat.core.entity.coupon.CouponItem;
import com.iamberry.wechat.core.entity.coupon.CouponItemDto;
import com.iamberry.wechat.core.entity.coupon.CouponType;
import com.iamberry.wechat.core.entity.ism.IntegralLog;
import com.iamberry.wechat.core.entity.member.Member;
import com.iamberry.wechat.core.entity.order.NumberBacklogDto;
import com.iamberry.wechat.core.entity.order.Order;
import com.iamberry.wechat.face.coupon.CouponItemService;
import com.iamberry.wechat.face.coupon.CouponTypeService;
import com.iamberry.wechat.face.ism.IntegralLogService;
import com.iamberry.wechat.face.member.MemberService;
import com.iamberry.wechat.face.sendmsg.CodeService;
import com.iamberry.wechat.tools.*;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.iamberry.app.tool.log.RatFWLogger;
import com.iamberry.wechat.core.entity.mq.MQMessage;
import com.iamberry.wechat.core.entity.task.TaskModel;
import com.iamberry.wechat.core.entity.task.WechatTask;
import com.iamberry.wechat.core.entity.task.WechatTaskLogs;
import com.iamberry.wechat.face.order.AdminOrderService;
import com.iamberry.wechat.face.reback.RebackServices;
import com.iamberry.wechat.face.task.WechatTaskService;
import com.iamberry.zk.SpringContextHolder;
/**
 * @company	深圳爱贝源科技有限公司
 * @website www.iamberry.com
 * @author 	献
 * @tel		18271840547
 * @date	2016年11月3日
 * @explain	MQ模拟实现
 */
@Component(value="mqTask")
@Lazy(false)
public class MQTask implements InitializingBean {
	@Autowired
	private AdminOrderService adminOrderService;
	@Autowired
	private MQServiceProxy mQSerivce;
	@Autowired
	private RatFWLogger logger;
	@Autowired
	private WechatTaskService wechatTaskService;
	@Autowired
	private RebackServices rebackServices;
	@Autowired
	private CodeService codeService;
	@Autowired
	private MemberService memberService;
	@Autowired
	private CouponTypeService couponTypeService;
	@Autowired
	private CouponItemService couponItemService;
	@Autowired
	private SendMessageUtil sendMessageUtil;
	@Autowired
	private IntegralLogService integralLogService;

	private Lock lock = new ReentrantLock();

	@SuppressWarnings(value = {"unchecked", "rawtypes"})
	@Scheduled(cron = "0/30 * * * * ?")
	public void sendOrderService() {
		logger.info("------------task start-----------");
		// If the timer has not stopped, then the next time the timer can not start.
		lock.lock();

		try {
			// step 1, Gets the message that is not executed in the database.
			List<MQMessage> messages = mQSerivce.selectWaitHandlerMessage();
			if (messages == null || messages.size() <= 0) {
				return;
			}

			// step 2, Handle 10 messages at a time.
			for (MQMessage mqMessage : messages) {
				try {
					Object object = SpringContextHolder.getBean(mqMessage.getServiceHandlerObjectName());
					Class classes = object.getClass();
					Method method = classes.getMethod(mqMessage.getServiceHandlerMethodName(), MQMessage.class);
					if (method == null) {
						mqMessage.setServiceErrorMessage("Method is not defined:" + mqMessage.getServiceHandlerMethodName());
						mqMessage.setServiceStatus(2);
						continue;
					}
					// invoke Method.
					Object resultObject = method.invoke(object, mqMessage);
					if (!(resultObject instanceof Boolean)) {
						mqMessage.setServiceStatus(2);
						mqMessage.setServiceErrorMessage(mqMessage.getServiceHandlerObjectName() + "." + mqMessage.getServiceHandlerMethodName() + "()Return value is not type Boolean");
						continue;
					}
					if (!(Boolean) resultObject) {
						mqMessage.setServiceErrorMessage("invoke Method Error");
						mqMessage.setServiceStatus(2);
						continue;
					}
					mqMessage.setServiceStatus(1);
					continue;
				} catch (Exception e) {
					// TODO: handle exception
					mqMessage.setServiceErrorMessage(e.getMessage());
					mqMessage.setServiceStatus(2);
					continue;
				} finally {
					mqMessage.setServiceIsSend(1);
				}
			}

			// step 3, update Message status and serviceIsSend.
			mQSerivce.updateBatchMessage(messages);

			// step 4, is next ?
			/*if (messages.size() >= 10) {
				StaticCacheMemory.isStartTask = true;
				this.sendOrderService();
			}*/
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e, "MQ Task Error:" + e.getMessage());
		} finally {
			// reset lock
			lock.unlock();
		}
		logger.info("------------task invoke success-----------");
	}

	/**
	 * 根据订单号拉取物流信息
	 * @throws Exception
	 */
	@Scheduled(cron = "0 0 */1 * * ?")//每小时执行一次
	//@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	//@Scheduled(cron = "*/10 * * * * ?")
	public void syncLgisticsInfoByOrderId() throws Exception {
		System.out.println("---------------- 根据订单号拉取物流信息开始 ---------------");
		logger.info("---------------- 根据订单号拉取物流信息开始 ---------------");
		lock.lock();
		List<Order> orderList = null;
		String url = NameUtils.getConfig("rst_efast_base_url");
		String sdId = NameUtils.getConfig("sd_id");
		Map<String, Object> orderData = new HashMap<String, Object>();
		Map<String, String> requestData = new HashMap<String, String>();
		com.fasterxml.jackson.databind.ObjectMapper mapper = new ObjectMapper();
		try {
			logger.info("---------------- selectProbationShopOrderList begin ---------------");
			orderList = wechatTaskService.selectAiberleShopOrderList();
			if(orderList != null && orderList.size() > 0){
				for (Order order:orderList) {
					String salesOrderid = order.getSalesOrderid();
					orderData.put("orderId", salesOrderid);
					orderData.put("sd_id", sdId);
					requestData.put("app_act", "rst.trade.logistics.get");
					String orderDataStr = mapper.writeValueAsString(orderData);
					requestData.put("info", orderDataStr);
					String result = HttpClient431Util.doPost(requestData, url);
					result = StringEscapeUtils.unescapeJava(result); // unicode 编码
					logger.info("拉取订单号为:" + order.getSalesOrderid() + "的订单，rst返回信息:" + result);
					JSONObject jsonObject = JSONObject.fromObject(result);
					String msg = jsonObject.getString("msg");
					logger.info("---------"+msg+"---------");
					if ("success".equals(msg)) {
						Date date = new Date();
						String salesPostFirm = jsonObject.getString("salesPostFirm");
						String salesPostNum = jsonObject.getString("salesPostNum");
						order.setSalesPostFirm(salesPostFirm);
						order.setSalesPostNum(salesPostNum);
						order.setSalesSendDate(date);
						wechatTaskService.updateAiberleShopOrder(order);
					}
				}
			}
		}catch (Exception e){
			logger.error("拉取订单异常",e.getMessage());
		}finally {
			lock.unlock();
		}
		logger.info("---------------- 根据订单号拉取物流信息结束 ---------------");
	}

	/**
	 * 订阅消息
	 */
	public void subscribeMessageQueue() {
	}

	// 强迫线程可见
	private volatile boolean oldState = true;

	/**
	 * 微信定期任务奖励-上个月的定时器
	 */
	@SuppressWarnings("deprecation")
	@Scheduled(cron = "0/59 * * * * ?")
	public void oldMonthTask() {
		if (!oldState) {
			logger.info("线程正忙...");
			return;
		}
		oldState = false;
		try {
			// 判断上一个月的数据是否奖励完成
			logger.info("上一个月的定时奖励任务奖励...");
			// 当前时间
			Date nowDate = new Date();

			// 回到上一个月
			nowDate.setMonth(nowDate.getMonth() - 1);
			// 上一个月的结束时间  类似 ：2016-02-29 23:59:59
			Date oldMonthLastDay = DateTimeUtil.getLastDayOfYear(nowDate);
			// 上一个月的开始时间  类似 ：2016-02-01 00:00:00
			Date oldMonthFirstDay = DateTimeUtil.getFirstDayOfYear(nowDate);

			List<WechatTask> tasks = wechatTaskService.getRunTask(oldMonthFirstDay, oldMonthLastDay);
			if (tasks == null || tasks.size() == 0) {
				logger.info("暂时没有上一个月的任务奖励...");
				oldState = true;
				return;
			}
			// 获取在上一个月销售达到X台的数据
			for (WechatTask wechatTask : tasks) {
				List<TaskModel> models = rebackServices.getByDate(wechatTask.getTaskProductType(), oldMonthFirstDay, oldMonthLastDay, wechatTask.getTaskSalesNum());
				if (models == null || models.size() == 0) {
                    logger.info("暂时没有人完成上一个月的任务" + wechatTask.getTaskId() + "奖励...");
                    continue;
                }
				// 达到的用户是否已经领取奖励
				for (TaskModel taskModel : models) {
					WechatTaskLogs logs = new WechatTaskLogs();
					logs.setLogsTaskId(wechatTask.getTaskId());
					logs.setLogsUserOpenId(taskModel.getOpenID());
					Integer logsID = wechatTaskService.getByTaskIdAndOpenId(logs);
					if (logsID != null) {
						// 如果当前用户已经领取了奖励，那么跳过
						continue;
					}
					// 若用没有领取，那么奖励
					try {
						wechatTaskService.handlerTask(taskModel.getOpenID(), wechatTask.getTaskMoney(), wechatTask.getTaskId(), wechatTask.getTaskProductType());
					} catch (Exception e) {
						logger.error(this, "对:" + taskModel.getOpenID() + ",奖励失败!error:" + e.getMessage());
					}
				}
			}
		} catch (Exception e) {
			logger.error(this, "发生异常,奖励失败!error:" + e.getMessage());
		} finally {
			// 归还锁
			oldState = true;
		}
	}

	// 强迫线程可见
	private volatile boolean nowState = true;
	/**
	 * 微信定期任务奖励-本月的定时器
	 */
	@Scheduled(cron = "0/59 * * * * ?")
	public void nowMonthTask() {
		if (!nowState) {
			logger.info("线程正忙...");
			return;
		}
		nowState = false;

		try {
			// 判断本月是否有奖励数据
			logger.info("本月的定时奖励任务奖励...");
			// 当前时间
			Date nowDate = new Date();

			// 上一个月的结束时间  类似 ：2016-02-29 23:59:59
			Date oldMonthLastDay = DateTimeUtil.getLastDayOfYear(nowDate);
			// 上一个月的开始时间  类似 ：2016-02-01 00:00:00
			Date oldMonthFirstDay = DateTimeUtil.getFirstDayOfYear(nowDate);

			List<WechatTask> tasks = wechatTaskService.getRunTask(oldMonthFirstDay, oldMonthLastDay);
			if (tasks == null || tasks.size() == 0) {
				logger.info("暂时没有本月的任务奖励...");
				nowState = true;
				return;
			}
			// 获取在上一个月销售达到X台的数据
			for (WechatTask wechatTask : tasks) {
				List<TaskModel> models = rebackServices.getByDate(wechatTask.getTaskProductType(), oldMonthFirstDay, oldMonthLastDay, wechatTask.getTaskSalesNum());
				if (models == null || models.size() == 0) {
					logger.info("暂时没有人完成本月的任务" + wechatTask.getTaskId() + "奖励...");
					continue;
				}
				// 达到的用户是否已经领取奖励
				for (TaskModel taskModel : models) {
					WechatTaskLogs logs = new WechatTaskLogs();
					logs.setLogsTaskId(wechatTask.getTaskId());
					logs.setLogsUserOpenId(taskModel.getOpenID());
					Integer logsID = wechatTaskService.getByTaskIdAndOpenId(logs);
					if (logsID != null) {
						// 如果当前用户已经领取了奖励，那么跳过
						continue;
					}
					// 若用没有领取，那么奖励
					try {
						wechatTaskService.handlerTask(taskModel.getOpenID(), wechatTask.getTaskMoney(), wechatTask.getTaskId(), wechatTask.getTaskProductType());
					} catch (Exception e) {
						logger.error(this, "对:" + taskModel.getOpenID() + ",奖励失败!error:" + e.getMessage());
					}
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.error(this, "发生异常:" + e.getMessage());
		} finally {
			nowState = true;
		}
	}

	public void afterPropertiesSet() throws Exception {
	}

	/**
	 * 待处理订单提醒---每天下午2:50，短信提醒益霜、运营一次（15814645335、18271840547）；
	 */
//	@SuppressWarnings(value = {"unchecked", "rawtypes"})
//	@Scheduled(cron = "0 50 14 * * ?")//每天下午2点50分执行一次
//	public void pendingOrderReminder() {
//		logger.info("=======发送短信通知========");
//		//查询待发货事项、申请退款订单、申请退货订单、申请换货订单 的数量
//		NumberBacklogDto numberBacklogDto = adminOrderService.selectNumberBacklog();
//		Integer num = (numberBacklogDto.getExchange()+numberBacklogDto.getReturnGoods()+numberBacklogDto.getReturnRefund()+numberBacklogDto.getSendTheGoods());
//		String text = MessageFormat.format(ImberryConfig.PENDING_ORDER_REMINDER, num);
//		if(num > 0){
//			codeService.informShipping("15814645335", text);
//			codeService.informShipping("18271840547", text);
//		}
//	}

	/**
	 * 生日提醒 - 赠送优惠券 - 需要在0点就赠送出去
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0 */1 * * ?")//每小时执行一次
//	@Scheduled(cron = "0 0 9 * * ?")//每天早上9点触发
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 5 0 * * ?")//每天早上0点过5分执行
	public void birthDatePromptCoupon() throws Exception {
		logger.info("---------------- 生日提醒-赠送优惠券-开始 ---------------");
		List<Member> memberList = memberService.getNowBirthDate();
		logger.info("---今日生日的用户数量："+memberList.size());
		Integer couponId = 40000;
		for (Member member:memberList) {
			CouponType couponType = couponTypeService.getCouponTypeById(couponId);

			Calendar calendar = Calendar.getInstance();
			calendar.set(Calendar.HOUR_OF_DAY,23);
			calendar.set(Calendar.MINUTE,59);
			calendar.set(Calendar.SECOND,50);
			//创建优惠券
			CouponItem couponItem = new CouponItem();
			String uuidStr = StrUtils.getUUID();
			couponItem.setCouponItemId(uuidStr);
			couponItem.setCouponItemUseropenid(member.getUserOpenid());
			couponItem.setCouponId(couponType.getCouponId());
			couponItem.setCouponReceiveDate(new Date());
			couponItem.setCouponUseEndDate(calendar.getTime());
			couponItem.setCouponUseStatus(1);
			couponItem.setCouponItemRemark(couponType.getCouponRemark());
			Integer flag = couponItemService.insertCouponItem(couponItem);
			if(flag < 1){
				logger.info("---生日优惠券领取失败，userOpenId："+member.getUserOpenid() + "");
			}else{
				logger.info("---生日优惠券领取成功，userOpenId："+member.getUserOpenid() + "");
			}
		}
		logger.info("---------------- 生日提醒-赠送优惠券-结束 ---------------");
	}

	/**
	 * 生日提醒-9点通知客户今天优惠券和积分三倍情况
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0 */1 * * ?")//每小时执行一次
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 0 9 * * ?")//每天早上9点触发
	public void birthDatePrompt() throws Exception {
		logger.info("---------------- 生日提醒-提醒用户-开始 ---------------");
		List<Member> memberList = memberService.getNowBirthDate();
		logger.info("---今日生日的用户数量："+memberList.size());
		for (Member member:memberList) {
			//推送微信模板消息
			try {
				sendMessageUtil.memberActivation(
						"尊敬的会员，祝您生日快乐，特送上一份生日礼包。",
						member.getUserTel(),
						String.valueOf(member.getUserSurplusIntegral()),
						"1、免费领取50元代金券，满99元即可使用，在会员中心-券包即可查看使用。\\\\r\\\\n" +
								"2、会员生日当天下单购买产品，即可享受3倍积分。\\\\r\\\\n" +
								"生日福利仅限生日当天领取和使用，赶快享受你的专属生日礼包吧！",
						member.getUserOpenid(),
						ResultInfo.COUPON_URL);
			}catch (Exception e){
				logger.info("推送今日生日的用户消息失败，失败openId：" + member.getUserOpenid());
				e.printStackTrace();
			}
		}
		logger.info("---------------- 生日提醒-提醒用户-结束 ---------------");
	}


	/**
	 * 将待入账转为已入账
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 0 */1 * * ?")//每小时执行一次
	public void accountEntry() throws Exception {
		logger.info("---------------- 待入账转为已入账-开始 ---------------");
		List<IntegralLog> integralLogList = integralLogService.getIntegralLogListByWaitUser();
		if(integralLogList!=null && integralLogList.size()>0){
			logger.info("---------------- 当前待入账的处理数量-"+ integralLogList.size() +" ---------------");
			for (IntegralLog integralLog:integralLogList) {
				try {
					integralLogService.waitUser(integralLog);
				}catch (Exception e){
					logger.info("--待入账转为已入账失败；待入账积分记录id："+integralLog.getInteLogId()+"；" +
							"订单编号："+ integralLog.getInteLogWaitingOrderId() +";失败原因："+e.getMessage());
					e.printStackTrace();
				}
			}
			logger.info("---------------- 待入账转为已入账-结束 ---------------");
		}
	}

	/**
	 * 20分钟刷新-未支付订单自动取消订单
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 0/5 * * * ?")//每5分钟执行一次
	public void cancelOrder() throws Exception {
		logger.info("---------------- 超过20分钟取消订单-开始 ---------------");
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.MINUTE, -20);//20分钟前的时间

		Order order = new Order();
		order.setCancelDate(calendar.getTime());
		List<Order> orderList = adminOrderService.cancelOrderList(order);
		if(orderList!=null && orderList.size()>0){
			logger.info("---------------- 当前订单处理数量-"+ orderList.size() +" ---------------");
			for (Order ord:orderList) {
				try {
					Integer flag = adminOrderService.cancelOrder(ord.getSalesOrderid());
					if(flag < 1){
						logger.info("---------------- 订单取消失败-订单号："+ ord.getSalesOrderid() +" ---------------");
					}
				}catch (Exception e){
					e.printStackTrace();
					logger.info("---------------- 订单取消报错"+ e.getMessage() +"-订单号："+ ord.getSalesOrderid() +" ---------------");
				}
			}
			logger.info("---------------- 超过20分钟取消订单-结束 ---------------");
		}
	}

	/**
	 * 关注一个月后未注册，推送注册信息
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 0 8 * * ?")//每天早上9点触发
	public void mqRegisterMember() throws Exception {
		logger.info("---------------- 关注用户过一个月还未注册，推送注册信息-开始 ---------------");
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DATE, -30);//30天前

		Member member = new Member();
		member.setUserSubDate(calendar.getTime());
		List<Member> memberList = memberService.getNoRegister(member);

		if(memberList!=null && memberList.size()>0){
			logger.info("---------------- 当前任务处理数量-"+ memberList.size() +" ---------------");
			for (Member m:memberList) {
				try {
					sendMessageUtil.registerMember(
							"欢迎关注Aiberle爱贝源。现在注册会员可享受多重好礼：\\\\r\\\\n" +
									"1.专属折扣（购买滤芯88折，其他产品95折）\\\\r\\\\n" +
									"2.单支滤芯买一送一\\\\r\\\\n" +
									"3.注册即送100积分，下单可抵扣10元",
							"我的爱贝源-会员中心-成为会员",
							"400-8006692",
							"赶紧注册会员吧！更多惊喜等你来！",
							m.getUserOpenid(),
							ResultInfo.HUIYUAN_URL);
				}catch (Exception e){
					logger.info("关注用户过一个月还未注册，推送注册信息失败，失败openId：" + member.getUserOpenid());
					e.printStackTrace();
				}
			}
			logger.info("---------------- 关注用户过一个月还未注册，推送注册信息-结束 ---------------");
		}
 	}

	/**
	 * 注册会员但未使用优惠券
	 * 45天提醒一次  85天提醒一次
	 * @throws Exception
	 */
//	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
	@Scheduled(cron = "0 0 8 * * ?")//每天早上9点触发
	public void mqRecommendUseCoupon() throws Exception {
		logger.info("---------------- 注册会员未使用优惠券提醒-开始 ---------------");

		//45天未使用优惠券的券
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DATE, -45);//45天前
		CouponItem couponItem = new CouponItem();
		couponItem.setCouponId(40001);
		couponItem.setCouponReceiveDate(calendar.getTime());
		List<CouponItemDto> couponItemDtoList = couponItemService.getNoUseCouponList(couponItem);
		if(couponItemDtoList!=null && couponItemDtoList.size()>0){
			logger.info("---------------- 45天未使用优惠券的券 - 前当前任务处理数量-"+ couponItemDtoList.size() +" ---------------");
			for (CouponItemDto couponItemDto:couponItemDtoList) {
				try {
					sendMessageUtil.recommendUseCoupon(
							"亲爱的用户，您的单支滤芯买一送一优惠券即将到期",
							"单支滤芯买一送一",
							"45天后失效",
							"可在“服务中心-会员中心-券包”查看，请尽快使用。",
							couponItemDto.getUseropenid(),
							ResultInfo.COUPON_URL);
				}catch (Exception e){
					logger.info("注册成功提醒使用优惠券失败，失败openId：" + couponItemDto.getUseropenid()+",优惠券ID："+couponItemDto.getCouponItemId());
					e.printStackTrace();
				}
			}
			logger.info("---------------- 注册会员未使用优惠券提醒-结束 ---------------");
		}

		//85天未使用优惠券的券
		Calendar nowcalendar = Calendar.getInstance();
		nowcalendar.setTime(new Date());
		nowcalendar.add(Calendar.DATE, -85);//45天前
		CouponItem nowcouponItem = new CouponItem();
		nowcouponItem.setCouponId(40001);
		nowcouponItem.setCouponReceiveDate(nowcalendar.getTime());
		List<CouponItemDto> nowcouponItemDtoList = couponItemService.getNoUseCouponList(nowcouponItem);
		if(nowcouponItemDtoList!=null && nowcouponItemDtoList.size()>0){
			logger.info("---------------- 85天未使用优惠券的券 - 前当前任务处理数量-"+ nowcouponItemDtoList.size() +" ---------------");
			for (CouponItemDto couponItemDto:nowcouponItemDtoList) {
				try {
					sendMessageUtil.recommendUseCoupon(
							"亲爱的用户，您的单支滤芯买一送一优惠券即将到期",
							"单支滤芯买一送一",
							"5天后失效",
							"可在“服务中心-会员中心-券包”查看，请尽快使用。",
							couponItemDto.getUseropenid(),
							ResultInfo.COUPON_URL);
				}catch (Exception e){
					logger.info("注册成功提醒使用优惠券失败，失败openId：" + couponItemDto.getUseropenid()+",优惠券ID："+couponItemDto.getCouponItemId());
					e.printStackTrace();
				}
			}
		}
		logger.info("---------------- 注册会员未使用优惠券提醒-结束 ---------------");
	}
}
