【同步】BOOT 和 CLOUD 的功能

This commit is contained in:
YunaiV
2025-11-23 09:07:03 +08:00
parent a0b7777783
commit 69e595d62e
27 changed files with 156 additions and 64 deletions

View File

@@ -282,10 +282,11 @@ public class CouponServiceImpl implements CouponService {
if (ObjUtil.notEqual(couponTemplate.getTakeType(), takeType.getType())) {
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
}
// 校验发放数量不能过小(仅在 CouponTakeTypeEnum.USER 用户领取时)
// 校验剩余发放数量是否充足(仅在 CouponTakeTypeEnum.USER 用户领取时)
// 关联案例https://t.zsxq.com/mElGQ、https://t.zsxq.com/6pLzr
if (CouponTakeTypeEnum.isUser(couponTemplate.getTakeType())
&& ObjUtil.notEqual(couponTemplate.getTakeLimitCount(), CouponTemplateDO.TAKE_LIMIT_COUNT_MAX) // 校验不限制领取数
&& ObjUtil.notEqual(couponTemplate.getTotalCount(), CouponTemplateDO.TOTAL_COUNT_MAX)) { // 校验不限制发放数量
&& couponTemplate.getTakeCount() > couponTemplate.getTotalCount()) { // 已领取数量 >= 总发放数量
throw exception(COUPON_TEMPLATE_NOT_ENOUGH);
}
// 校验"固定日期"的有效期类型是否过期

View File

@@ -85,7 +85,9 @@ public interface DeliveryExpressTemplateConvert {
.setChargeMode(template.getChargeMode())
.setCharge(convertTemplateCharge(findFirst(templateIdChargeMap.get(template.getId()), charge -> charge.getAreaIds().contains(areaId))))
.setFree(convertTemplateFree(findFirst(templateIdFreeMap.get(template.getId()), free -> free.getAreaIds().contains(areaId))));
result.put(template.getId(), bo);
if (bo.getCharge() != null || bo.getFree() != null) {
result.put(template.getId(), bo);
}
});
return result;
}

View File

@@ -268,7 +268,9 @@ public interface TradeOrderConvert {
.setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName()))
.setFirstFixedPrice(0).setSecondFixedPrice(0);
if (BooleanUtil.isTrue(spu.getSubCommissionType())) {
bo.setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice());
// 特殊:单独设置的佣金需要乘以购买数量。关联 https://gitee.com/yudaocode/yudao-mall-uniapp/issues/ICY7SJ
bo.setFirstFixedPrice(sku.getFirstBrokeragePrice() * item.getCount())
.setSecondFixedPrice(sku.getSecondBrokeragePrice() * item.getCount());
}
return bo;
}

View File

@@ -29,7 +29,7 @@ public class BrokerageRecordDO extends BaseDO {
* 编号
*/
@TableId
private Integer id;
private Long id;
/**
* 用户编号
* <p>

View File

@@ -44,7 +44,7 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
.lt(BrokerageRecordDO::getUnfreezeTime, unfreezeTime));
}
default int updateByIdAndStatus(Integer id, Integer status, BrokerageRecordDO updateObj) {
default int updateByIdAndStatus(Long id, Integer status, BrokerageRecordDO updateObj) {
return update(updateObj, new LambdaQueryWrapper<BrokerageRecordDO>()
.eq(BrokerageRecordDO::getId, id)
.eq(BrokerageRecordDO::getStatus, status));

View File

@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.trade.service.aftersale;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
@@ -352,12 +353,20 @@ public class AfterSaleServiceImpl implements AfterSaleService {
throw exception(AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND);
}
// 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起
createPayRefund(userIp, afterSale);
Integer newStatus;
if (ObjUtil.equals(afterSale.getRefundPrice(), 0)) {
// 特殊:退款为 0 的订单直接标记为完成积分商城。关联案例https://t.zsxq.com/AQEvL
updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.WAIT_REFUND.getStatus(), new AfterSaleDO()
.setStatus(AfterSaleStatusEnum.COMPLETE.getStatus()).setRefundTime(LocalDateTime.now()));
newStatus = AfterSaleStatusEnum.COMPLETE.getStatus();
} else {
// 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起
createPayRefund(userIp, afterSale);
newStatus = afterSale.getStatus(); // 特殊:这里状态不变,而是最终 updateAfterSaleRefunded 处理!!!
}
// 记录售后日志
AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(),
afterSale.getStatus()); // 特殊:这里状态不变,而是最终 updateAfterSaleRefunded 处理!!!
AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
}
private void createPayRefund(String userIp, AfterSaleDO afterSale) {

View File

@@ -147,9 +147,10 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
userAccount = wallet.getId().toString();
}
// 1.2 构建请求
Integer transferPrice = withdraw.getPrice() - withdraw.getFeePrice(); // 计算实际转账金额(提现金额 - 手续费)
PayTransferCreateReqDTO transferReqDTO = new PayTransferCreateReqDTO()
.setAppKey(tradeOrderProperties.getPayAppKey()).setChannelCode(channelCode)
.setMerchantTransferId(withdraw.getId().toString()).setSubject("佣金提现").setPrice(withdraw.getPrice())
.setMerchantTransferId(withdraw.getId().toString()).setSubject("佣金提现").setPrice(transferPrice)
.setUserAccount(userAccount).setUserName(userName).setUserIp(getClientIP())
.setUserId(withdraw.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) // 用户信息
.setChannelExtras(channelExtras);
@@ -280,9 +281,10 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
throw exception(BROKERAGE_WITHDRAW_UPDATE_STATUS_FAIL_PAY_TRANSFER_STATUS_NOT_SUCCESS_OR_CLOSED);
}
// 2.2 校验转账金额一致
if (ObjectUtil.notEqual(payTransfer.getPrice(), withdraw.getPrice())) {
log.error("[validateBrokerageTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账金额不匹配请进行处理withdraw 数据是:{}payTransfer 数据是:{}]",
withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer));
Integer expectedTransferPrice = withdraw.getPrice() - withdraw.getFeePrice(); // 转账金额 = 提现金额 - 手续费
if (ObjectUtil.notEqual(payTransfer.getPrice(), expectedTransferPrice)) {
log.error("[validateBrokerageTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账金额不匹配请进行处理withdraw 数据是:{}payTransfer 数据是:{},期望转账金额:{}]",
withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer), expectedTransferPrice);
throw exception(BROKERAGE_WITHDRAW_UPDATE_STATUS_FAIL_PAY_PRICE_NOT_MATCH);
}
// 2.3 校验转账订单匹配