feat:测试bug
This commit is contained in:
1 parent
24f17f011d
commit
912a36978a
10 files changed
+48
-23
No files matched your search
+3
-7
@@ -10,13 +10,9 @@ public class HardCreateActOrderDto {
|
||||
@Schema(description = "活动类型")
|
||||
private String actType;
|
||||
|
||||
@Schema(description = "活动id")
|
||||
@NotNull(message = "活动id")
|
||||
private Long actId;
|
||||
|
||||
@Schema(description = "总金额不能为空")
|
||||
@NotNull(message = "总金额")
|
||||
private Integer totalPrice;
|
||||
@Schema(description = "核销id")
|
||||
@NotNull(message = "核销id不能为空")
|
||||
private Long cancelId;
|
||||
|
||||
@Schema(description = "核销用户id")
|
||||
private Long cancelUserId;
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ public class HardOrderController {
|
||||
|
||||
@Operation(summary = "app创建活动订单", description = "app创建活动订单")
|
||||
@PostMapping("/app/create-act-order")
|
||||
@Idempotent(expireTime = 5, info = "正在创建订单中,请勿重复操作")
|
||||
@Idempotent(expireTime = 3, key = "'/hard-order/app/create-act-order' + #body.getCancelId() ", info = "正在创建订单中,请勿重复操作")
|
||||
public R<Long> appCreateActOrder(@Validated @RequestBody HardCreateActOrderDto body) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
body.setCancelUserId(user.getId());
|
||||
|
||||
+8
-6
@@ -770,16 +770,18 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
* 创建活动订单
|
||||
*/
|
||||
@Override
|
||||
@Lock4j(keys = {"#dto.getActId()"})
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long appCreateActOrder(HardCreateActOrderDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getCancelUserId())) throw new RuntimeException("核销用户不能为空");
|
||||
// 查询活动详情
|
||||
ActCancelItemVo actDetail = remoteActCancelService.getDetail(dto.getActId()).getData();
|
||||
ActCancelItemVo actDetail = remoteActCancelService.getDetail(dto.getCancelId()).getData();
|
||||
if (ObjectUtil.isEmpty(actDetail)) throw new RuntimeException("活动不存在");
|
||||
if (ObjectUtil.isNotEmpty(actDetail.getExpireTime())) {
|
||||
if (actDetail.getExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,您领取的优惠券已过期");
|
||||
if (actDetail.getActExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,活动已结束");
|
||||
}
|
||||
if (actDetail.getActStartTime().isAfter(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,活动未开始");
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.equals(actDetail.getActStatus(), ActCancelStatusEnum.CANCEL_SUCCESS.getCode())) {
|
||||
@@ -826,7 +828,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.orderType(HardOrderTypeEnum.RESERVE.getType())
|
||||
.payType(HardPayTypeEnum.ACT_CANCEL.getType())
|
||||
.orderSourceTypeId(dto.getActId())
|
||||
.orderSourceTypeId(dto.getCancelId())
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
.payPrice(totalPrice)
|
||||
@@ -837,7 +839,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
baseMapper.insert(orderObj);
|
||||
// 核销
|
||||
ActCancelItemDto cancelDto = new ActCancelItemDto();
|
||||
cancelDto.setActId(dto.getActId());
|
||||
cancelDto.setId(dto.getCancelId());
|
||||
cancelDto.setCancelUserId(dto.getCancelUserId());
|
||||
R<Boolean> cancelVo = remoteActCancelService.cancel(cancelDto);
|
||||
if (ObjectUtil.notEqual(cancelVo.getCode(), CommonConstants.SUCCESS)) {
|
||||
|
||||
+6
@@ -51,6 +51,12 @@ public class ActCancelEntity extends Model<ActCancelEntity> {
|
||||
@Schema(description = "活动核销价")
|
||||
private Integer activeCancelPrice;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Schema(description = "开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 到期时间
|
||||
*/
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public interface RemoteActCancelService {
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/act/cancel-item/get-detail")
|
||||
R<ActCancelItemVo> getDetail(@RequestParam Long id);
|
||||
R<ActCancelItemVo> getDetail(@RequestParam Long cancelId);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/act/cancel-item/cancel")
|
||||
|
||||
+5
@@ -33,6 +33,11 @@ public class ActCancelItemVo extends ActCancelItemEntity {
|
||||
*/
|
||||
private String actTitlel;
|
||||
|
||||
/**
|
||||
* 活动开始时间
|
||||
*/
|
||||
private LocalDateTime actStartTime;
|
||||
|
||||
/**
|
||||
* 活动结束时间
|
||||
*/
|
||||
|
||||
+2
-2
@@ -37,8 +37,8 @@ public class ActCancelItemController {
|
||||
@Inner()
|
||||
@Operation(summary = "查询优惠券详情", description = "查询优惠券详情")
|
||||
@GetMapping("/get-detail")
|
||||
public R<ActCancelItemVo> getDetail(@RequestParam Long id) {
|
||||
return R.ok(actCancelItemService.getDetail(id));
|
||||
public R<ActCancelItemVo> getDetail(@RequestParam Long cancelId) {
|
||||
return R.ok(actCancelItemService.getDetail(cancelId));
|
||||
}
|
||||
|
||||
@Inner()
|
||||
|
||||
+1
-1
@@ -35,5 +35,5 @@ public interface ActCancelItemService extends IService<ActCancelItemEntity> {
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
ActCancelItemVo getDetail(Long id);
|
||||
ActCancelItemVo getDetail(Long cancelId);
|
||||
}
|
||||
+20
-5
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.act;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -129,6 +130,7 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
if (ObjectUtil.isNotEmpty(act)) {
|
||||
item.setActTitlel(act.getActTitle());
|
||||
item.setActExpireTime(act.getExpireTime());
|
||||
item.setActStartTime(act.getStartTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,6 +148,16 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
if (ObjectUtil.equals(act.getActStatus(), ActStatusEnum.ACT_CANCEL.getCode())) {
|
||||
throw new RuntimeException("核销活动已关闭");
|
||||
}
|
||||
|
||||
// 判断是否在时间内
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (act.getExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,活动已结束");
|
||||
}
|
||||
if (act.getStartTime().isAfter(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,活动未开始");
|
||||
}
|
||||
|
||||
// 获取商户
|
||||
MchManageEntity actMch = mchManageService.getById(dto.getMchId());
|
||||
if (ObjectUtil.isEmpty(actMch)) throw new RuntimeException("核销活动商户不存在");
|
||||
@@ -160,7 +172,6 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
throw new RuntimeException("消费钱包余额不足" + cancelPrice + "元,无法领取");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireTime = act.getExpireTime();
|
||||
|
||||
ActCancelItemEntity saveObj = new ActCancelItemEntity();
|
||||
@@ -224,12 +235,12 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
*/
|
||||
@Override
|
||||
public Boolean cancel(ActCancelItemDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getActId()) || ObjectUtil.isEmpty(dto.getCancelUserId())) {
|
||||
if (ObjectUtil.isEmpty(dto.getId()) || ObjectUtil.isEmpty(dto.getCancelUserId())) {
|
||||
log.error("|{}|核销失败,参数错误", TAG);
|
||||
return false;
|
||||
}
|
||||
// 查询活动
|
||||
ActCancelItemEntity detail = baseMapper.selectById(dto.getActId());
|
||||
ActCancelItemEntity detail = baseMapper.selectById(dto.getId());
|
||||
if (ObjectUtil.isEmpty(detail)) {
|
||||
log.error("|{}|核销失败,活动不存在", TAG);
|
||||
return false;
|
||||
@@ -261,9 +272,11 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
* 查询详情
|
||||
*/
|
||||
@Override
|
||||
public ActCancelItemVo getDetail(Long id) {
|
||||
public ActCancelItemVo getDetail(Long cancelId) {
|
||||
ActCancelItemVo result = new ActCancelItemVo();
|
||||
ActCancelItemEntity detail = baseMapper.selectById(id);
|
||||
ActCancelItemEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<ActCancelItemEntity>()
|
||||
.eq(ActCancelItemEntity::getId, cancelId)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(detail)) return null;
|
||||
result = BeanUtils.toBean(detail, ActCancelItemVo.class);
|
||||
// 查询活动
|
||||
@@ -271,6 +284,8 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
if (ObjectUtil.isNotEmpty(actDetail)) {
|
||||
result.setActiveCancelPrice(actDetail.getActiveCancelPrice());
|
||||
}
|
||||
result.setActStartTime(actDetail.getStartTime());
|
||||
result.setActExpireTime(actDetail.getExpireTime());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
a.notice_id,
|
||||
a.active_org_price,
|
||||
a.active_cancel_price,
|
||||
a.start_time,
|
||||
a.expire_time,
|
||||
a.act_status,
|
||||
a.act_title,
|
||||
|
||||
Reference in new issue
Block a user