feat:优化领取判断

This commit is contained in:
dzc committed 2026-01-31 13:58:41 +08:00
1 parent 684762fb6c
commit 7f72fa0244
2 files changed
+23 -6

No files matched your search

@@ -20,6 +20,10 @@ public enum ActUserReceiveEnum {
USER_CANNOT_PARTICIPATE("5", "用户不能参加此活动"), USER_CANNOT_PARTICIPATE("5", "用户不能参加此活动"),
OTHER_ERROR("6", "其他错误"), OTHER_ERROR("6", "其他错误"),
USER_CAN_JOIN_ACT("99", "用户可以参加活动"), USER_CAN_JOIN_ACT("99", "用户可以参加活动"),
// 特殊
PLEASE_RECEIVE_IN_BIRTH_MONTH("-100", "请在生日当月领取"),
PLEASE_FILL_BIRTH_DATE("-101", "请填写出生日期"),
; ;
private final String code; private final String code;
@@ -2,6 +2,8 @@ package com.bsd.pjcloud.wallet.service.impl.act;
import cn.hutool.core.collection.IterUtil; import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -22,6 +24,7 @@ import com.bsd.pjcloud.wallet.api.constant.act.ActUserReceiveEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto; import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActCouponReceiveDto; import com.bsd.pjcloud.wallet.api.dto.act.ActCouponReceiveDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActCouponRecordDto; import com.bsd.pjcloud.wallet.api.dto.act.ActCouponRecordDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity; import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponRecordEntity; import com.bsd.pjcloud.wallet.api.entity.act.ActCouponRecordEntity;
@@ -61,7 +64,7 @@ public class ActCouponRecordServiceImpl extends ServiceImpl<ActCouponRecordMappe
private final ActCouponComUtilService actCouponComUtilService; private final ActCouponComUtilService actCouponComUtilService;
private final ActCouponService actCouponService; private final ActCouponService actCouponService;
private final WalletTypeService walletTypeService; private final WalletManageService walletManageService;
private final WalletCodeUseService walletCodeUseService; private final WalletCodeUseService walletCodeUseService;
private final RemoteUserService remoteUserService; private final RemoteUserService remoteUserService;
@@ -163,28 +166,38 @@ public class ActCouponRecordServiceImpl extends ServiceImpl<ActCouponRecordMappe
if (ObjectUtil.equals(uniqueCode, "1qRgFo")) { if (ObjectUtil.equals(uniqueCode, "1qRgFo")) {
// 判断是否为食堂用户 // 判断是否为食堂用户
MchManageVo userMch = mchManageService.getFirstMchByDeptId(sysUser.getDeptId(), List.of(MerchantTypeEnum.CANTEEN)); MchManageVo userMch = mchManageService.getFirstMchByDeptId(sysUser.getDeptId(), List.of(MerchantTypeEnum.CANTEEN));
if (ObjectUtil.isEmpty(userMch)) { if (ObjectUtil.isEmpty(userMch) && false) {
log.info("|{}|{}用户参加{}活动失败:不是食堂用户", TAG, sysUser.getName(), uniqueCode); log.info("|{}|{}用户参加{}活动失败:不是食堂用户,用户属于食堂{}", TAG, sysUser.getName(), uniqueCode, JSONUtil.toJsonStr(userMch));
return ActUserReceiveEnum.USER_CANNOT_PARTICIPATE; return ActUserReceiveEnum.USER_CANNOT_PARTICIPATE;
} }
// 判断用户最近一年充值是否为500,1500,800,2400 // 判断用户最近一年充值是否为500,1500,800,2400
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(WalletTypeEnum.EAT); WalletManageEntity userWallet = walletManageService.getWallet(sysUser.getUserId(), WalletTypeEnum.EAT);
WalletTransactionDto dto = new WalletTransactionDto(); WalletTransactionDto dto = new WalletTransactionDto();
dto.setWalletTypeId(walletType.getId()); dto.setWalletId(userWallet.getId());
dto.setBizTypes(WalletBizEnum.getTopUpCodes()); dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_INCOME); dto.setType(WalletTransactionDto.TYPE_INCOME);
dto.setUserId(sysUser.getUserId()); dto.setUserId(sysUser.getUserId());
dto.setPriceList(List.of(500 * 100, 1500 * 100, 800 * 100, 2400 * 100)); dto.setPriceList(List.of(500 * 100, 1500 * 100, 800 * 100, 2400 * 100));
dto.setCreateTimeList(new LocalDate[]{ dto.setCreateTimeList(new LocalDate[]{
LocalDate.now().minusMonths(4), LocalDate.now().minusMonths(4),
LocalDate.now() LocalDate.now().plusDays(1)
}); });
List<WalletTransactionVo> walletList = walletTransactionMapper.scopeList(dto, null); List<WalletTransactionVo> walletList = walletTransactionMapper.scopeList(dto, null);
if (ObjectUtil.isEmpty(walletList)) { if (ObjectUtil.isEmpty(walletList)) {
log.info("|{}|{}用户参加{}活动失败:用户最近一年充值金额不足500,1500,800,2400", TAG, sysUser.getName(), uniqueCode); log.info("|{}|{}用户参加{}活动失败:用户最近一年充值金额不足500,1500,800,2400", TAG, sysUser.getName(), uniqueCode);
return ActUserReceiveEnum.USER_CANNOT_PARTICIPATE; return ActUserReceiveEnum.USER_CANNOT_PARTICIPATE;
} }
// 要在生日当月领取
LocalDate birthday = sysUser.getBirthday();
if (ObjectUtil.isEmpty(birthday)) {
log.info("|{}|{}用户参加{}活动失败:请填写生日", TAG, sysUser.getName(), uniqueCode);
return ActUserReceiveEnum.PLEASE_FILL_BIRTH_DATE;
}
if (ObjectUtil.notEqual(LocalDate.now().getMonth().getValue(), birthday.getMonth().getValue())) {
log.info("|{}|{}用户参加{}活动成功:在生日当月领取", TAG, sysUser.getName(), uniqueCode);
return ActUserReceiveEnum.PLEASE_RECEIVE_IN_BIRTH_MONTH;
}
return ActUserReceiveEnum.USER_CAN_JOIN_ACT; return ActUserReceiveEnum.USER_CAN_JOIN_ACT;
} }
return null; return null;