feat:活动领取修改
This commit is contained in:
1 parent
090d362a82
commit
24a685ae0c
4 files changed
+18
-7
No files matched your search
+1
-1
@@ -35,7 +35,7 @@ public class ActCancelController {
|
||||
|
||||
@Operation(summary = "根据公告id查询活动", description = "根据公告id查询活动")
|
||||
@GetMapping("/app/detail-by-notice-id")
|
||||
public R getDetailByNoticeId(@RequestParam Long id) {
|
||||
public R<ActCancelEntity> getDetailByNoticeId(@RequestParam Long id) {
|
||||
return R.ok(actCancelService.getDetailByNoticeId(id));
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.wallet.controller.act;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -57,15 +58,16 @@ public class ActCancelItemController {
|
||||
@PostMapping("/app/get")
|
||||
@Idempotent(expireTime = 2, key = "'/act/cancel/app/get/' + #dto.getReceiverUserId()", info = "正在领取中,请勿重复操作")
|
||||
public R<Long> appGet(@RequestBody ActCancelItemDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getActId())) throw new RuntimeException("活动id不能为空");
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
return R.ok(actCancelItemService.appGet(user, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "app查询用户的唯一优惠券", description = "app查询用户的唯一优惠券")
|
||||
@GetMapping("/app/find-unique")
|
||||
public R<ActCancelItemVo> appFindUnique() {
|
||||
public R<ActCancelItemVo> appFindUnique(@RequestParam Long actId) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
return R.ok(actCancelItemService.appFindUnique(user));
|
||||
return R.ok(actCancelItemService.appFindUnique(actId, user));
|
||||
}
|
||||
|
||||
@Operation(summary = "app查询本店优惠券列表", description = "app查询本店优惠券列表")
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public interface ActCancelItemService extends IService<ActCancelItemEntity> {
|
||||
/**
|
||||
* 查询用户的唯一优惠券
|
||||
*/
|
||||
ActCancelItemVo appFindUnique(PjcloudUser user);
|
||||
ActCancelItemVo appFindUnique(Long actId, PjcloudUser user);
|
||||
|
||||
/**
|
||||
* app查询本店优惠券列表
|
||||
|
||||
+12
-3
@@ -32,6 +32,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -121,6 +123,9 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
*/
|
||||
@Override
|
||||
public Long appGet(PjcloudUser user, ActCancelItemDto dto) {
|
||||
// 查询活动
|
||||
ActCancelEntity act = actCancelMapper.selectById(dto.getActId());
|
||||
if (ObjectUtil.isEmpty(act)) throw new RuntimeException("核销活动不存在");
|
||||
// 获取商户
|
||||
MchManageEntity actMch = null;
|
||||
try {
|
||||
@@ -136,9 +141,12 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
// 判断是否已经领取
|
||||
if (existAct(user.getId())) throw new RuntimeException("您已经领,请勿重复领取");
|
||||
|
||||
// 查询余是否大于1元
|
||||
// 查询余是否大于核销价格
|
||||
WalletManageEntity wallet = walletManageService.getWallet(user.getId(), WalletTypeEnum.PAY);
|
||||
if (wallet.getBalance() < 100) throw new RuntimeException("消费钱包余额不足1元,无法领取");
|
||||
String cancelPrice = new BigDecimal(act.getActiveOrgPrice()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
if (wallet.getBalance() < act.getActiveOrgPrice()) {
|
||||
throw new RuntimeException("消费钱包余额不足" + cancelPrice + "元,无法领取");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireTime = now.plusDays(90);
|
||||
@@ -159,8 +167,9 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
* 查询用户的唯一优惠券
|
||||
*/
|
||||
@Override
|
||||
public ActCancelItemVo appFindUnique(PjcloudUser user) {
|
||||
public ActCancelItemVo appFindUnique(Long actId, PjcloudUser user) {
|
||||
ActCancelItemEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<ActCancelItemEntity>()
|
||||
.eq(ActCancelItemEntity::getActId, actId)
|
||||
.eq(ActCancelItemEntity::getReceiverUserId, user.getId())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(detail)) throw new RuntimeException("您未领取优惠券,请前往领取");
|
||||
|
||||
Reference in new issue
Block a user