feat:额外收费

This commit is contained in:
dzc committed 2026-03-26 11:05:42 +08:00
1 parent 54a431891a
commit 33ff7edc2e
46 files changed
+955 -26

No files matched your search

@@ -121,6 +121,8 @@ public interface HardOrderService extends IService<HardOrderEntity> {
Integer computeExtraPrice(Integer price, MchManageVo mch, SysUser sysUser);
Integer computeExtraPriceV2(Integer totalPrice, Long mchId, String hourType, Long userId, Long userDeptId);
/**
* 核销二维码
*/
@@ -34,6 +34,7 @@ import com.bsd.pjcloud.hard.api.dto.order.*;
import com.bsd.pjcloud.hard.api.dto.wechat.WechatRefundDto;
import com.bsd.pjcloud.hard.api.entity.order.*;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.manager.HardManagerVo;
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
@@ -46,6 +47,8 @@ import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.*;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeRefundDto;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
import com.bsd.pjcloud.wallet.api.vo.WalletXfjDiscounts;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -74,14 +77,16 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
private final HardOrderService hardOrderService;
private final WechatPayService wechatPayService;
private final AlipayService alipayService;
private final HardCarService hardCarService;
private final HardAfterSaleCarService hardAfterSaleCarService;
private final HardManagerService hardManagerService;
private final HardOrderMapper hardOrderMapper;
private final RemoteUserService userService;
private final RemoteDeptService deptService;
private final RemoteWalletRechargeService walletRechargeService;
private final HardCarService hardCarService;
private final HardAfterSaleCarService hardAfterSaleCarService;
private final RemoteWalletSettingService walletSettingService;
@Override
@@ -411,6 +416,11 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
if (totalPrice > order.getPayPrice()) {
throw new RuntimeException("退款总金额大于支付总金额");
}
// 查询设备信息
HardManagerVo hardDetail = hardManagerService.getByHardId(order.getHardId());
if (ObjectUtil.isNotEmpty(hardDetail)) {
orderVo.setHardType(hardDetail.getType());
}
return orderVo;
}
@@ -559,6 +569,16 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
return entity;
}).toList();
refundPrice = hardCarService.computerCarTotalPrice(HardTypeEnum.valueOfByType(order.getSysType()), HardOrderTypeEnum.valueOfByType(order.getOrderType()), computerCarList);
// TODO 特殊如果是食堂会有额外收费记得退款
if (ObjectUtil.equals(order.getHardType(), HardTypeEnum.CANTEEN.getType()) && ObjectUtil.isNotEmpty(order.getExtraPrice()) && order.getExtraPrice() > 0) {
int noRefundPrice = order.getPayPrice() - order.getExtraPrice() - refundPrice;
if (noRefundPrice >= 0) {
Integer noRefundExtraPrice = hardOrderService.computeExtraPriceV2(noRefundPrice, order.getMerchantId(), order.getHourType(), order.getUserId(), order.getUserDeptId());
if (noRefundExtraPrice == 0) {
refundPrice += order.getExtraPrice();
}
}
}
}
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
@@ -94,6 +94,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.WalletXfjDiscounts;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActComItemVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
@@ -301,7 +302,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
int totalPrice = 0, extraPrice = 0, payPrice = 0;
totalPrice = hardCarService.computerCarTotalPrice(dto.getSysType(), dto.getOrderType(), dto.getList());
if (isExtraPrice) extraPrice = computeExtraPrice(totalPrice, mch, sysUser);
if (isExtraPrice) {
extraPrice = computeExtraPriceV2(totalPrice, mch.getId(), String.valueOf(dto.getHourType()), sysUser.getUserId(), sysUser.getDeptId());
}
payPrice = totalPrice + extraPrice;
if (isWalletPay) {
// 如果是支付的话,不能小于等于0
@@ -1132,6 +1135,19 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return extraPrice;
}
@Override
public Integer computeExtraPriceV2(Integer totalPrice, Long mchId, String hourType, Long userId, Long userDeptId) {
List<WalletXfjDiscounts> discountsList = walletSettingService.remoteGetDiscountsList(String.valueOf(mchId), userId, userDeptId).getData();
if (ObjectUtil.isEmpty(discountsList)) {
return 0;
}
return discountsList.stream()
.filter(item -> ObjectUtil.equals(item.getHourType(), String.valueOf(hourType)))
.map(item -> item.computedDiscountsExtraPrice(totalPrice))
.reduce(Integer::sum).orElse(0);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean handCancelCode(HandCancelCodeDto dto) {