短信发放 券发放

This commit is contained in:
wangw 2025-10-17 18:25:32 +08:00
parent a970d129e0
commit 9a196e4d4a
2 changed files with 15 additions and 13 deletions

View File

@ -111,7 +111,6 @@ public class AShopUserServiceImpl implements AShopUserService {
@Override
public List<ShopUser> getPushEventUserList(SmsPushEventUser smsPushEventUser) {
List<Long> shopUserIds = new ArrayList<>();
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
smsPushEventUser.checkIsAll();
// 调用Mapper层查询

View File

@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -133,25 +134,20 @@ public class SmsPushEventServiceImpl extends ServiceImpl<SmsPushEventMapper, Sms
// 推送消息 进行 消息发送
rabbitPublisher.sendApplySmsMsg(pushEvent.getShopId() + "," + pushEvent.getId(), "sendMarkSms");
//发放优惠券
CompletableFuture.runAsync(() -> {
try {
grantCoupon(param);
} catch (Exception e) {
log.error("异步发放优惠券失败", e);
}
});
grantCoupon(param);
}
@Override
public void sendPushEventCoupon(String eventId) {
SmsPushEventDTO pushEvent = getObjAs(new QueryWrapper().eq(SmsPushEvent::getId, eventId), SmsPushEventDTO.class);
AssertUtil.isNull(pushEvent, "券发放失败,推送事件不存在");
SmsPushEvent smsPushEvent = getOne(new QueryWrapper().eq(SmsPushEvent::getId, eventId));
AssertUtil.isNull(smsPushEvent, "券发放失败,推送事件不存在");
SmsPushEventDTO pushEvent = BeanUtil.toBean(smsPushEvent, SmsPushEventDTO.class);
SmsPushEventUser eventUser = eventUserMapper.selectOneByQuery(
new QueryWrapper().eq(SmsPushEventUser::getEventId, eventId)
);
AssertUtil.isNull(eventUser, "券发放失败,推送事件用户群体不存在");
pushEvent.setSmsPushEventUser(eventUser);
if (pushEvent.getSendType() == 1 && StrUtil.isNotBlank(pushEvent.getCoupon())) {
if (StrUtil.isNotBlank(pushEvent.getCoupon())) {
grantCoupon(pushEvent);
}
}
@ -162,7 +158,14 @@ public class SmsPushEventServiceImpl extends ServiceImpl<SmsPushEventMapper, Sms
//发放优惠券
CompletableFuture.runAsync(() -> {
try {
List<ShopUser> userList = shopUserService.getPushEventUserList(param.getSmsPushEventUser());
SmsPushEventUser smsPushEventUser = param.getSmsPushEventUser();
List<ShopUser> userList = new ArrayList<>();
if (param.getUserType() == 1) {
smsPushEventUser = new SmsPushEventUser();
smsPushEventUser.setShopId(param.getShopId());
smsPushEventUser.setIsAll(1);
}
userList = shopUserService.getPushEventUserList(smsPushEventUser);
// 2. 将JSON字符串解析为JSONArray
JSONArray couponArray = JSON.parseArray(param.getCoupon());