From 23249eea35c9167fb70447ceff99c32364339ac5 Mon Sep 17 00:00:00 2001 From: "taylor.dang" Date: Thu, 13 Sep 2018 20:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/impls/ActRedPackServiceImpl.java | 16 +++++++++------- .../payment/manage/task/RedPackTaskManager.java | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java index 23e82d56c..dbf53cad7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java @@ -123,7 +123,7 @@ public class ActRedPackServiceImpl implements ActRedPackService { } if (ruleOrderTotal != null) { if (!(currencyAmount.compareTo(ruleOrderTotal) >= 0)) { - logger.info("订单金额不满足活动要求金额"); + logger.info("订单金额不满足 [{}] 红包活动要求金额",actName); return; } } @@ -133,29 +133,29 @@ public class ActRedPackServiceImpl implements ActRedPackService { int getTotalCounts = getRedPacketsByOpenid(customerId, new Date(), actId); int ruleMaxNum = redpackCustomerActivity.getIntValue("rule_max_num"); if (getTotalCounts >= ruleMaxNum) { - logger.debug("customerId:" + customerId + "已达到本次活动发送最大次数" + ruleMaxNum + "!跳过"); + logger.debug("customerId:" + customerId + "已达到本次 [{}] 红包活动发送最大次数" + ruleMaxNum + "!跳过",actName); return; } int getDailyTotalCounts = getRedPacketsByOpenid(customerId, new Date(), actId); int ruleMaxNumLimit = redpackCustomerActivity.getIntValue("rule_max_num_limit"); if (getDailyTotalCounts >= ruleMaxNumLimit) { - logger.debug("customerId:" + customerId + "已达当日发送最大次数" + ruleMaxNumLimit + "!跳过"); + logger.debug("customerId:" + customerId + "已达 [{}] 红包活动当日发送最大次数" + ruleMaxNumLimit + "!跳过",actName); return; } - takeRedpack(actId, orderId, clientId, clientApply, currencyAmount, customerId, 0); + takeRedpack(actId, orderId, clientId, clientApply, currencyAmount, customerId,actName, 0); } - private void takeRedpack(String actId, String orderId, int clientId, JSONObject clientApply, BigDecimal currencyAmount, String customerId, int tryTimes) + private void takeRedpack(String actId, String orderId, int clientId, JSONObject clientApply, BigDecimal currencyAmount, String customerId, String actName, int tryTimes) throws RedPackException { if (tryTimes > 5) { return; } int random = (int) (Math.random() * 100); if (random > 80) { - logger.info("未达到触发概率当前概率为:" + random); + logger.info("未达到 [{}] 红包活动触发概率,当前概率为:" + random, actName); return; } @@ -177,7 +177,7 @@ public class ActRedPackServiceImpl implements ActRedPackService { doSendWechatActLuckyMoney(customerId, lock, clientApply.getString("act_name"), clientApply.getString("send_name"), clientApply.getString("wishing")); break; } else { - takeRedpack(actId, orderId, clientId, clientApply, currencyAmount, customerId, tryTimes + 1); + takeRedpack(actId, orderId, clientId, clientApply, currencyAmount, customerId, actName, tryTimes + 1); break; } } @@ -186,6 +186,7 @@ public class ActRedPackServiceImpl implements ActRedPackService { @Override public void doSendWechatActLuckyMoney(String paymentOpenId, String lock, String actName, String sendName, String wishing) throws RedPackException { + logger.info("开始给支付用户 [{}] 发送 [{}--{}]红包", paymentOpenId, actName, lock); JSONObject prizeDetail = actRedPacketsCustomerOrdersMapper.findLockedPrize(lock, paymentOpenId); BigDecimal luckyMoeny = prizeDetail.getBigDecimal("red_packet_amount"); String redPackOrderId = prizeDetail.getString("red_packet_order_id"); @@ -216,6 +217,7 @@ public class ActRedPackServiceImpl implements ActRedPackService { prizeDetail.put("red_packet_id", redPacketId); prizeDetail.put("status", 1); actRedPacketsCustomerOrdersMapper.update(prizeDetail); + logger.info("支付用户 [{}] 发送 [{}--{}] 红包结束", paymentOpenId, actName, lock); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java b/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java index 790670dc6..f42cfa782 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java @@ -16,7 +16,7 @@ import javax.annotation.Resource; * Created by yishuqian on 01/02/2017. */ @Component -@ConditionalOnProperty(value = "app.run-tasks", havingValue = "false") +@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") public class RedPackTaskManager { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -32,7 +32,7 @@ public class RedPackTaskManager { synchronizedScheduler.executeProcess("manage_task:updateRedpackStatus", 120_000, () -> redpackService.updateRedPacketsStatus("3")); } - @Scheduled(cron = "0 0/10 * * * ?") +// @Scheduled(cron = "0 0/10 * * * ?") public void updateAlipayRedPackStatus() { synchronizedScheduler.executeProcess("manage_task:updateAlipayRedpackStatus", 120_000, () -> redpackService.updateAlipayRedPacketsStatus("3")); } @@ -40,6 +40,8 @@ public class RedPackTaskManager { @Scheduled(cron = "0 0/3 * * * *") public void resendFailedRedpack() { + logger.info("auto resend Redpack Task Fired!"); synchronizedScheduler.executeProcess("manage_task:resendFailedRedpack", 120_000, () -> actRedPackService.resendFailed()); + logger.info("auto resend Redpack Task End!"); } }