Merge branch 'develop'

master
taylor.dang 6 years ago
commit 9129c0d0a2

@ -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

@ -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");
}
}

Loading…
Cancel
Save