生日有礼发放修改
This commit is contained in:
parent
3a1c30398c
commit
a685819158
|
|
@ -65,6 +65,7 @@ public class MkBirthdayGiftRecord implements Serializable {
|
|||
private String templateContent;
|
||||
private String phone;
|
||||
private Long templateId;
|
||||
private Integer year;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||
|
||||
@Override
|
||||
public void deliver() {
|
||||
DateTime now = DateUtil.date();
|
||||
list(new QueryWrapper().eq(MkBirthdayGift::getIsEnable, 1)).forEach(birthdayGift -> {
|
||||
if (StrUtil.isNotBlank(birthdayGift.getConfigList())) {
|
||||
SmsShopTemplate shopTemplate;
|
||||
|
|
@ -168,19 +169,20 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||
current = current.plusDays(config.getDeliverTime());
|
||||
}
|
||||
} else {
|
||||
DateTime now = DateUtil.date();
|
||||
// 获取当月第一天
|
||||
current = DateUtil.beginOfMonth(now).toLocalDateTime().toLocalDate();
|
||||
}
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper().isNotNull(ShopUser::getBirthDay)
|
||||
.eq(ShopUser::getMainShopId, birthdayGift.getMainShopId()).eq(ShopUser::getBirthDay, current);
|
||||
.eq(ShopUser::getMainShopId, birthdayGift.getMainShopId())
|
||||
.eq("DATE_FORMAT(birth_day, '%m-%d')", DateUtil.format(DateUtil.date(current), "MM-dd"));
|
||||
if ("vip".equals(config.getUserType())) {
|
||||
queryWrapper.eq(ShopUser::getIsVip, 1);
|
||||
}
|
||||
|
||||
for (ShopUser shopUser : shopUserService.list(queryWrapper)) {
|
||||
long count = birthdayGiftRecordService.count(new QueryWrapper().eq(MkBirthdayGiftRecord::getUserId, shopUser.getUserId()).eq(MkBirthdayGiftRecord::getBirthday, current));
|
||||
long count = birthdayGiftRecordService.count(new QueryWrapper().eq(MkBirthdayGiftRecord::getUserId, shopUser.getUserId())
|
||||
.eq(MkBirthdayGiftRecord::getYear, DateUtil.year(now)));
|
||||
if (count > 1) {
|
||||
log.info("用户{}已领取过生日礼包", shopUser.getUserId());
|
||||
continue;
|
||||
|
|
@ -191,6 +193,7 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||
TableValueConstant.BirthdayGiftRecord.PushStatus.WAIT_PUSH.getCode() : TableValueConstant.BirthdayGiftRecord.PushStatus.NO_PUSH.getCode())
|
||||
.setMainShopId(birthdayGift.getMainShopId()).setBirthday(DateUtil.parseDate(shopUser.getBirthDay()).toLocalDateTime().toLocalDate())
|
||||
.setPhone(shopUser.getPhone()).setTemplateId(shopTemplate == null ? null : shopTemplate.getId())
|
||||
.setYear(DateUtil.year(now))
|
||||
.setSourceId(birthdayGift.getId()).setTemplateCode(shopTemplate == null ? null : shopTemplate.getTemplateCode()).setTemplateContent(JSONObject.toJSONString(Map.of(
|
||||
"用户昵称", shopUser.getNickName(),
|
||||
"店铺名称", shopInfo.getShopName(),
|
||||
|
|
@ -221,9 +224,7 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||
}, "优惠券发放失败");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue