生日有礼相关
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -213,4 +214,40 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public MkBirthdayGiftVO getInfo(long userId, Integer shopId) {
|
||||
MkBirthdayGift birthdayGift = getOne(new QueryWrapper().eq(MkBirthdayGift::getMainShopId, shopId).eq(MkBirthdayGift::getIsEnable, 1));
|
||||
if (birthdayGift == null) {
|
||||
return null;
|
||||
}
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getMainShopId, shopId));
|
||||
if (StrUtil.isBlank(birthdayGift.getConfigList())) {
|
||||
return null;
|
||||
}
|
||||
LocalDate current = DateUtil.date().toLocalDateTime().toLocalDate();
|
||||
for (MkBirthdayGiftConfig config : JSONArray.parseArray(birthdayGift.getConfigList()).toJavaList(MkBirthdayGiftConfig.class)) {
|
||||
if ("day".equals(config.getDeliverDate())) {
|
||||
if (config.getDeliverTime() != 1) {
|
||||
current = current.plusDays(config.getDeliverTime());
|
||||
}
|
||||
} else {
|
||||
DateTime now = DateUtil.date();
|
||||
// 获取当月第一天
|
||||
current = DateUtil.beginOfMonth(now).toLocalDateTime().toLocalDate();
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(shopUser.getBirthDay())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (DateUtil.parseDate(shopUser.getBirthDay()).toLocalDateTime().toLocalDate().isEqual(current)) {
|
||||
MkBirthdayGiftVO vo = BeanUtil.copyProperties(birthdayGift, MkBirthdayGiftVO.class, "configList");
|
||||
vo.setConfigList(CollUtil.toList(config));
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user