feat:bug
This commit is contained in:
1 parent
07f3770897
commit
8ca9854b01
3 files changed
+34
-9
No files matched your search
+3
-1
@@ -29,6 +29,7 @@ public enum HardPayTypeEnum {
|
||||
ZYY("12", "中医院"),
|
||||
RMYY("13", "人民医院"),
|
||||
CSXFK("14", "超市消费卡"),
|
||||
ACT_CANCEL("50", "活动核销"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
@@ -70,7 +71,8 @@ public enum HardPayTypeEnum {
|
||||
|
||||
// 简单支付(没有购物车)
|
||||
public static final List<HardPayTypeEnum> isSimplePayList = List.of(
|
||||
WALLET_QR_CODE_SCAN
|
||||
WALLET_QR_CODE_SCAN,
|
||||
ACT_CANCEL
|
||||
);
|
||||
|
||||
public static HardPayTypeEnum valueOfByType(String type) {
|
||||
|
||||
+18
-3
@@ -73,6 +73,7 @@ import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionCallbackDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.act.ActCancelStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchRulePriceTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
|
||||
@@ -686,13 +687,21 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
* 创建活动订单
|
||||
*/
|
||||
@Override
|
||||
@Lock4j(keys = {"hard", "#dto.getActId()"})
|
||||
@Lock4j(keys = {"#dto.getActId()"})
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long appCreateActOrder(HardCreateActOrderDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getCancelUserId())) throw new RuntimeException("核销用户不能为空");
|
||||
// 查询活动详情
|
||||
ActCancelItemEntity actDetail = remoteActCancelService.getDetail(dto.getActId()).getData();
|
||||
if (ObjectUtil.isEmpty(actDetail)) throw new RuntimeException("活动不存在");
|
||||
if (ObjectUtil.isNotEmpty(actDetail.getExpireTime())) {
|
||||
if (actDetail.getExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,您领取的优惠券已过期");
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.equals(actDetail.getActStatus(), ActCancelStatusEnum.CANCEL_SUCCESS.getCode())) {
|
||||
throw new RuntimeException("核销失败,您领取的优惠券已核销");
|
||||
}
|
||||
|
||||
// 查询活动商户
|
||||
MchManageVo mch = remoteMchService.getById(actDetail.getMchId()).getData();
|
||||
@@ -701,10 +710,15 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 查询核销人
|
||||
UserInfo cancelUserDetail = userService.getInnerByUserId(dto.getCancelUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(cancelUserDetail)) throw new RuntimeException("核销用户不存在不存在");
|
||||
if (ObjectUtil.isEmpty(cancelUserDetail.getRoleCodes()) || Arrays.asList(cancelUserDetail.getRoleCodes()).contains(CommonRoleConstant.MCH_USER)) {
|
||||
if (ObjectUtil.isEmpty(cancelUserDetail.getRoleCodes()) || !Arrays.asList(cancelUserDetail.getRoleCodes()).contains(CommonRoleConstant.MCH_USER)) {
|
||||
throw new RuntimeException("当前用户没有核销权限");
|
||||
}
|
||||
|
||||
MchManageVo cancelUserMch = remoteMchService.getFirstMch(List.of(cancelUserDetail.getSysUser().getDeptId()), MerchantTypeEnum.SUPERMARKET).getData();
|
||||
if(ObjectUtil.isEmpty(cancelUserMch) || ObjectUtil.notEqual(cancelUserMch.getId(), actDetail.getMchId())){
|
||||
throw new RuntimeException("当前活动,该用户没有核销权限");
|
||||
}
|
||||
|
||||
// 查询用户
|
||||
UserInfo userDetail = userService.getInnerByUserId(actDetail.getReceiverUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("领券用户不存在不存在");
|
||||
@@ -728,7 +742,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.sysType(HardTypeEnum.MERCHANT_ACT.getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.orderType(HardOrderTypeEnum.RESERVE.getType())
|
||||
.payType(HardPayTypeEnum.WALLET_DEFAULT.getType())
|
||||
.payType(HardPayTypeEnum.ACT_CANCEL.getType())
|
||||
.orderSourceTypeId(dto.getActId())
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
@@ -737,6 +751,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.productDesc(subject)
|
||||
.walletId(wallet.getId())
|
||||
.build();
|
||||
baseMapper.insert(orderObj);
|
||||
// 核销
|
||||
ActCancelItemDto cancelDto = new ActCancelItemDto();
|
||||
cancelDto.setActId(dto.getActId());
|
||||
|
||||
+13
-5
@@ -133,7 +133,7 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
if (wallet.getBalance() < 100) throw new RuntimeException("消费钱包余额不足1元,无法领取");
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireTime = now.plusDays(30);
|
||||
LocalDateTime expireTime = now.plusDays(90);
|
||||
|
||||
ActCancelItemEntity saveObj = new ActCancelItemEntity();
|
||||
saveObj.setActId(-1L);
|
||||
@@ -181,21 +181,29 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
|
||||
*/
|
||||
@Override
|
||||
public Boolean cancel(ActCancelItemDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getId()) || ObjectUtil.isEmpty(dto.getCancelUserId())) {
|
||||
if (ObjectUtil.isEmpty(dto.getActId()) || ObjectUtil.isEmpty(dto.getCancelUserId())) {
|
||||
log.error("|{}|核销失败,参数错误", TAG);
|
||||
return false;
|
||||
}
|
||||
// 查询活动
|
||||
ActCancelItemEntity detail = baseMapper.selectById(dto.getId());
|
||||
ActCancelItemEntity detail = baseMapper.selectById(dto.getActId());
|
||||
if (ObjectUtil.isEmpty(detail)) {
|
||||
log.error("|{}|核销失败,活动不存在", TAG);
|
||||
return false;
|
||||
}
|
||||
// 查询核销用户
|
||||
UserInfo userDetail = remoteUserService.getByUserId(dto.getCancelUserId()).getData();
|
||||
UserInfo userDetail = remoteUserService.getInnerByUserId(dto.getCancelUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userDetail)) {
|
||||
log.error("|{}|核销失败,核销用户不存在", TAG);
|
||||
return false;
|
||||
throw new RuntimeException("核销失败,核销用户不存在");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detail.getExpireTime())) {
|
||||
if (detail.getExpireTime().isBefore(LocalDateTime.now())) {
|
||||
throw new RuntimeException("核销失败,您领取的优惠券已过期");
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.equals(detail.getActStatus(), ActCancelStatusEnum.CANCEL_SUCCESS.getCode())) {
|
||||
throw new RuntimeException("核销失败,您领取的优惠券已核销");
|
||||
}
|
||||
ActCancelItemEntity updateObj = new ActCancelItemEntity();
|
||||
updateObj.setId(detail.getId());
|
||||
|
||||
Reference in new issue
Block a user