This commit is contained in:
dzc committed 2025-05-23 17:43:25 +08:00
1 parent f3b0891b56
commit 90bfb4121f
8 files changed
+44 -28

No files matched your search

@@ -260,16 +260,13 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
.build();
if (isPay) {
orderObj.setWalletId(wallet.getId());
} else {
orderObj.setPayPrice(0);
}
baseMapper.insert(orderObj);
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
// 钱包扣款
if (isPay) {
getSelf().fastReduceBalance(orderObj);
} else {
getSelf().fastReduceBalance(orderObj);
if (!isPay) {
// 核销二维码
getSelf().cancelCode(orderObj, userDetail);
}
@@ -529,28 +526,27 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
@Transactional(rollbackFor = Exception.class)
public void fastReduceBalance(HardOrderEntity order) {
boolean isPay = isPay(HardOrderTypeEnum.valueOfByType(order.getOrderType()), HardPayTypeEnum.valueOfByType(order.getPayType()));
WalletBalanceTransactionDto reduceBuild = new WalletBalanceTransactionDto();
reduceBuild.setWalletId(order.getWalletId());
reduceBuild.setPrice(order.getPayPrice());
reduceBuild.setBizId(String.valueOf(order.getId()));
reduceBuild.setBizType(WalletBizEnum.PAYMENT);
reduceBuild.setForce(true);
R<WalletTransactionEntity> reduceRes = walletTransactionService.reduceWalletBalance(reduceBuild);
if (reduceRes.getCode() != 0 || ObjectUtil.isEmpty(reduceRes.getData())) {
throw new RuntimeException("钱包扣款错误");
}
WalletTransactionEntity walletTransaction = reduceRes.getData();
if (ObjectUtil.isNotEmpty(walletTransaction)) {
// 订单表订单状态
Integer payPrice = isPay ? order.getTotalPrice() + order.getExtraPrice() : 0;
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
baseMapper.updateById(update);
// 父购物车订单表订单状态
if (ObjectUtil.isNotEmpty(order.getParentCarId())) {
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
hardParentCarServiceImpl.updateById(updateParentCar);
if (isPay) {
WalletBalanceTransactionDto reduceBuild = new WalletBalanceTransactionDto();
reduceBuild.setWalletId(order.getWalletId());
reduceBuild.setPrice(order.getPayPrice());
reduceBuild.setBizId(String.valueOf(order.getId()));
reduceBuild.setBizType(WalletBizEnum.PAYMENT);
reduceBuild.setForce(true);
R<WalletTransactionEntity> reduceRes = walletTransactionService.reduceWalletBalance(reduceBuild);
if (reduceRes.getCode() != 0 || ObjectUtil.isEmpty(reduceRes.getData())) {
throw new RuntimeException("钱包扣款错误");
}
}
// 订单表订单状态
Integer payPrice = isPay ? order.getTotalPrice() + order.getExtraPrice() : 0;
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
baseMapper.updateById(update);
// 父购物车订单表订单状态
if (ObjectUtil.isNotEmpty(order.getParentCarId())) {
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
hardParentCarServiceImpl.updateById(updateParentCar);
}
}
@Override
@@ -16,4 +16,9 @@ public class WalletForeignDto extends WalletForeignEntity {
private Boolean isFindCheckUser = false;
/**
* 是否查询已使用完的
*/
private Boolean isFindUsed = true;
}
@@ -14,4 +14,9 @@ public class WalletStrideDto extends WalletStrideEntity {
private Boolean isFindCheckUser = false;
/**
* 是否查询已使用完的
*/
private Boolean isFindUsed = true;
}
@@ -62,6 +62,7 @@ public class WalletForeignController {
public R<Page<WalletForeignVo>> appPageJoin(@ParameterObject Page page, @ParameterObject WalletForeignDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindUsed(false);
return R.ok(walletForeignService.pageJoin(page, dto));
}
@@ -58,6 +58,7 @@ public class WalletStrideController {
public R appPageJoin(@ParameterObject Page page, @ParameterObject WalletStrideDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindUsed(false);
return R.ok(walletStrideService.pageJoin(page, dto));
}
@@ -23,6 +23,7 @@ public interface WalletForeignMapper extends PjcloudBaseMapper<WalletForeignEnti
.eqIfExists(WalletForeignEntity::getProcessStatus, dto.getProcessStatus())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletForeignEntity::getDeptId, dto.getDeptIds())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletForeignEntity::getUserId, dto.getUserIds())
.ne(!dto.getIsFindUsed(), WalletForeignEntity::getCount, WalletForeignEntity::getUseCount)
.orderByDesc(WalletForeignEntity::getCreateTime)
.orderByDesc(WalletForeignEntity::getId);
return selectJoinPage(page, WalletForeignVo.class, wrapper);
@@ -8,6 +8,7 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.WalletStrideDto;
import com.bsd.pjcloud.wallet.api.entity.WalletForeignEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletStrideEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletStrideVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -23,6 +24,7 @@ public interface WalletStrideMapper extends PjcloudBaseMapper<WalletStrideEntity
.eqIfExists(WalletStrideEntity::getProcessStatus, dto.getProcessStatus())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletStrideEntity::getDeptId, dto.getDeptIds())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletStrideEntity::getUserId, dto.getUserIds())
.ne(!dto.getIsFindUsed(), WalletForeignEntity::getCount, WalletForeignEntity::getUseCount)
.orderByDesc(WalletStrideEntity::getCreateTime)
.orderByDesc(WalletStrideEntity::getId);
return selectJoinPage(page, WalletStrideVo.class, wrapper);
@@ -200,6 +200,10 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
public Boolean cancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
.eq(WalletCodeUseEntity::getBizId, id)
.eq(WalletCodeUseEntity::getStatus, YesNoEnum.NO.getCode())
.last(" limit 1")
.orderByDesc(WalletCodeUseEntity::getCreateTime)
.orderByDesc(WalletCodeUseEntity::getId)
);
if (ObjectUtil.isEmpty(codeUse)) return null;
if (ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode())) return false;
@@ -227,11 +231,12 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean isCancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
// 跨单位和外来人员有多张二维码
Long count = baseMapper.selectCount(new LambdaQueryWrapper<WalletCodeUseEntity>()
.eq(WalletCodeUseEntity::getBizId, id)
.eq(WalletCodeUseEntity::getStatus, YesNoEnum.NO.getCode())
);
if (ObjectUtil.isEmpty(codeUse)) return null;
return ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode());
return count <= 0;
}
/**