feat:活动
This commit is contained in:
1 parent
a8061efa2f
commit
24f17f011d
5 files changed
+71
-10
No files matched your search
+12
@@ -3,6 +3,8 @@ package com.bsd.pjcloud.wallet.api.vo.act;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ActCancelItemVo extends ActCancelItemEntity {
|
||||
|
||||
@@ -26,4 +28,14 @@ public class ActCancelItemVo extends ActCancelItemEntity {
|
||||
*/
|
||||
private Integer activeCancelPrice;
|
||||
|
||||
/**
|
||||
* 活动名称
|
||||
*/
|
||||
private String actTitlel;
|
||||
|
||||
/**
|
||||
* 活动结束时间
|
||||
*/
|
||||
private LocalDateTime actExpireTime;
|
||||
|
||||
}
|
||||
+7
@@ -39,6 +39,13 @@ public class ActCancelController {
|
||||
return R.ok(actCancelService.getDetailByNoticeId(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据活动id查询核销活动", description = "根据活动id查询核销活动")
|
||||
@GetMapping("/app/detail-by-id")
|
||||
public R<ActCancelEntity> getDetailById(@RequestParam Long id) {
|
||||
return R.ok(actCancelService.getDetailById(id));
|
||||
}
|
||||
|
||||
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
|
||||
+5
@@ -27,6 +27,11 @@ public interface ActCancelService extends IService<ActCancelEntity> {
|
||||
*/
|
||||
ActCancelEntity getDetailByNoticeId(Long noticeId);
|
||||
|
||||
/**
|
||||
* 根据活动id查询核销活动
|
||||
*/
|
||||
ActCancelEntity getDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 根据ids删除
|
||||
*/
|
||||
|
||||
+36
-9
@@ -12,10 +12,10 @@ import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.act.ActCancelStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.act.ActStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelEntity;
|
||||
@@ -116,6 +116,23 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Long> actIds = list.stream().map(ActCancelItemVo::getActId).distinct().filter(ObjectUtil::isNotEmpty).toList();
|
||||
if (ObjectUtil.isNotEmpty(actIds)) {
|
||||
// 活动信息
|
||||
List<ActCancelEntity> actList = actCancelMapper.selectList(new LambdaQueryWrapper<ActCancelEntity>()
|
||||
.in(ActCancelEntity::getId, actIds)
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(actList)) {
|
||||
Map<Long, ActCancelEntity> actMap = CollectionUtils.convertMap(actList, ActCancelEntity::getId);
|
||||
for (ActCancelItemVo item : list) {
|
||||
ActCancelEntity act = actMap.get(item.getActId());
|
||||
if (ObjectUtil.isNotEmpty(act)) {
|
||||
item.setActTitlel(act.getActTitle());
|
||||
item.setActExpireTime(act.getExpireTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,25 +143,28 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
// 查询活动
|
||||
ActCancelEntity act = actCancelMapper.selectById(dto.getActId());
|
||||
if (ObjectUtil.isEmpty(act)) throw new RuntimeException("核销活动不存在");
|
||||
if (ObjectUtil.equals(act.getActStatus(), ActStatusEnum.ACT_CANCEL.getCode())) {
|
||||
throw new RuntimeException("核销活动已关闭");
|
||||
}
|
||||
// 获取商户
|
||||
MchManageEntity actMch = mchManageService.getById(dto.getMchId());
|
||||
if (ObjectUtil.isEmpty(actMch)) throw new RuntimeException("核销活动商户不存在");
|
||||
|
||||
// 判断是否已经领取
|
||||
if (existAct(user.getId())) throw new RuntimeException("您已经领,请勿重复领取");
|
||||
if (existAct(user.getId(), dto.getActId())) throw new RuntimeException("您已经领,请勿重复领取");
|
||||
|
||||
// 查询余是否大于核销价格
|
||||
WalletManageEntity wallet = walletManageService.getWallet(user.getId(), WalletTypeEnum.PAY);
|
||||
String cancelPrice = new BigDecimal(act.getActiveOrgPrice()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
if (wallet.getBalance() < act.getActiveOrgPrice()) {
|
||||
String cancelPrice = new BigDecimal(act.getActiveCancelPrice()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
if (wallet.getBalance() < act.getActiveCancelPrice()) {
|
||||
throw new RuntimeException("消费钱包余额不足" + cancelPrice + "元,无法领取");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireTime = now.plusDays(90);
|
||||
LocalDateTime expireTime = act.getExpireTime();
|
||||
|
||||
ActCancelItemEntity saveObj = new ActCancelItemEntity();
|
||||
saveObj.setActId(-1L);
|
||||
saveObj.setActId(dto.getActId());
|
||||
saveObj.setMchId(actMch.getId());
|
||||
saveObj.setReceiverUserId(user.getId());
|
||||
saveObj.setReceiverUserName(user.getName());
|
||||
@@ -160,17 +180,23 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
*/
|
||||
@Override
|
||||
public ActCancelItemVo appFindUnique(Long actId, PjcloudUser user) {
|
||||
// 查询活动
|
||||
ActCancelEntity act = actCancelMapper.selectById(actId);
|
||||
if (ObjectUtil.isEmpty(act)) throw new RuntimeException("核销活动不存在");
|
||||
ActCancelItemEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<ActCancelItemEntity>()
|
||||
.eq(ActCancelItemEntity::getActId, actId)
|
||||
.eq(ActCancelItemEntity::getReceiverUserId, user.getId())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(detail)) throw new RuntimeException("您未领取优惠券,请前往领取");
|
||||
if (ObjectUtil.isEmpty(detail)) return null;
|
||||
if (ObjectUtil.isNotEmpty(detail.getExpireTime())) {
|
||||
if (detail.getExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("您领取的优惠券已过期");
|
||||
}
|
||||
}
|
||||
return BeanUtil.toBean(detail, ActCancelItemVo.class);
|
||||
ActCancelItemVo result = BeanUtil.toBean(detail, ActCancelItemVo.class);
|
||||
result.setActTitlel(act.getActTitle());
|
||||
result.setActExpireTime(act.getExpireTime());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,9 +275,10 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
}
|
||||
|
||||
// 判断车牌号是否重复
|
||||
private boolean existAct(Long userId) {
|
||||
private boolean existAct(Long userId, Long actId) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<ActCancelItemEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(userId), ActCancelItemEntity::getReceiverUserId, userId)
|
||||
.eq(ObjectUtil.isNotEmpty(actId), ActCancelItemEntity::getActId, actId)
|
||||
);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
+11
-1
@@ -68,7 +68,7 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
|
||||
*/
|
||||
@Override
|
||||
public Long create(ActCancelDto dto) {
|
||||
if (existByNoticeId(dto)) throw new RuntimeException("绑定的公告已存在核销活动");
|
||||
if (existByNoticeId(dto.getId(), dto.getNoticeId())) throw new RuntimeException("绑定的公告已存在核销活动");
|
||||
ActCancelEntity savObj = BeanUtils.toBean(dto, ActCancelEntity.class);
|
||||
if (ObjectUtil.isEmpty(savObj.getActStatus())) {
|
||||
savObj.setActStatus(ActStatusEnum.ACT_OPEN.getCode());
|
||||
@@ -87,6 +87,16 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据公告id查询核销活动
|
||||
*/
|
||||
@Override
|
||||
public ActCancelEntity getDetailById(Long id) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<ActCancelEntity>()
|
||||
.eq(ActCancelEntity::getId, id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ids删除
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user