Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
Tankaikai 2024-11-27 16:04:37 +08:00
commit 831d828588
4 changed files with 29 additions and 9 deletions

View File

@ -97,6 +97,17 @@ public interface TableConstant {
}
@Getter
public enum PayType {
CREDIT_BUYER("creditBuyer");
private final String value;
PayType(String value) {
this.value = value;
}
}
@Getter
public enum UseType {
TAKEOUT("takeout"),

View File

@ -31,5 +31,6 @@ public class PayDTO {
private Integer pointsNum;
private Integer staffId;
private String loginName;
private String creditBuyerId;
}

View File

@ -171,15 +171,15 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
// 账户余额
BigDecimal accountBalance = creditBuyer.getAccountBalance();
// 如果有余额的话从余额里面扣除没有余额的话从信用额度里面扣除余额和信用额度都为0则不允许挂账余额+信用额度刚好够支付这笔订单的话需要同时减余额减信用额度
if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getPayAmount())) {
if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getOrderAmount())) {
// 减余额
creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getPayAmount()));
creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getOrderAmount()));
tbCreditBuyerMapper.updateById(creditBuyer);
// 记录还款记录
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
record.setCreditBuyerId(creditBuyerId);
record.setOrderId(orderId);
record.setRepaymentAmount(orderInfo.getPayAmount());
record.setRepaymentAmount(orderInfo.getOrderAmount());
record.setPaymentMethod("余额支付");
record.setPaymentTime(new Date());
record.setRemark("挂账时余额充足,直接从余额扣除");
@ -188,7 +188,7 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
TbCreditBuyerOrder entity = new TbCreditBuyerOrder();
entity.setCreditBuyerId(creditBuyerId);
entity.setOrderId(orderId);
entity.setPaidAmount(orderInfo.getPayAmount());
entity.setPaidAmount(orderInfo.getOrderAmount());
entity.setStatus("paid");
entity.setLastPaymentTime(new Date());
entity.setLastPaymentMethod(record.getPaymentMethod());
@ -219,14 +219,14 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
entity.setLastPaymentMethod(record.getPaymentMethod());
entity.setRemark(record.getRemark());
//super.save(entity);
orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getPayAmount(), accountBalance));
orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getOrderAmount(), accountBalance));
}
// 剩余挂账额度
BigDecimal remainingAmount = creditBuyer.getRemainingAmount();
// 验证挂账金额是否大于剩余额度
boolean greater = NumberUtil.isGreater(orderInfo.getPayAmount(), remainingAmount);
boolean greater = NumberUtil.isGreater(orderInfo.getOrderAmount(), remainingAmount);
if (greater) {
throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getPayAmount(), remainingAmount));
throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getOrderAmount(), remainingAmount));
}
if (entity == null) {
entity = new TbCreditBuyerOrder();
@ -237,4 +237,4 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
}
return super.saveOrUpdate(entity);
}
}
}

View File

@ -134,6 +134,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
private final TbShopUserMapper tbShopUserMapper;
private final ThirdPartyCouponService thirdPartyCouponService;
private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService;
private final TbCreditBuyerOrderService creditBuyerOrderService;
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) {
// 获取当前台桌最新订单先付款模式不获取
@ -2141,7 +2142,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
// 获取优惠券信息
OrderCouponInfoDTO couponInfo = new OrderCouponInfoDTO();
if (!payDTO.getUserCouponInfos().isEmpty()) {
if (payDTO.getUserCouponInfos() != null && !payDTO.getUserCouponInfos().isEmpty()) {
couponInfo = getCouponInfo(payDTO.getVipUserId(), payDTO.getShopId(), payDTO.getUserCouponInfos(),
orderInfo.getOrderAmount(), productIdSet);
}
@ -2281,6 +2282,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
boolean isOnline = false;
switch (payDTO.getPayType()) {
case "creditBuyer":
if (payDTO.getCreditBuyerId() == null) {
throw new BadRequestException("挂单人不为空");
}
creditBuyerOrderService.save(payDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId()));
orderInfo.setPayType(TableConstant.OrderInfo.PayType.CREDIT_BUYER.getValue());
break;
case "vipPay":
if (payDTO.getVipUserId() != null) {
orderInfo.setUserId(String.valueOf(payDTO.getVipUserId()));